I started studying "First Unity" on the official Unity website.
using System.Collections;
using System.Collections.General;
using UnityEngine;
public class DangerWall:MonoBehavior {
// Callback called when in contact with an object
void OnCollisionEnter (Collision hit)
{
// If the tag of the object you contacted is "Player"
if(hit.gameObject.CompareTag("Player")){
// Get current scene number
intsceneIndex=SceneManager.GetActiveScene().buildIndex;
SceneManager.LoadScene(sceneIndex);
}
}
}
The error only occurs in
int sceneIndex=SceneManager.GetActiveScene().buildIndex;
SceneManager.LoadScene(sceneIndex);
in the
section of
eSceneManager does not exist in this context br
The error appears.
Please tell me where the problem is!
Obstacle and Restart→The use seems to be insufficient compared to the re-read scene code.
This may be the cause of the error.
using the link
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
using UnityEngine.SceneManagement;
is required.
© 2025 OneMinuteCode. All rights reserved.