Hello, I need helps with the scripting for reloading the current scene.
I know there is already similar discussion and answer about this but it doesn’t work out mine for some reason. I am not expert coding but this should work?
I am making a 3D floating platform game where if you fell out the platform, you hit R key to restart the current scene but the script doesn’t work for some reason;
using UnityEngine;
using System.Collections;
public class reload : MonoBehaviour{
void Update(){
if(Input.GetKeyDown(KeyCode.R)){
Scene scene = SceneManager.GetActiveScene(); SceneManager.LoadScene(scene.name);
}
}
}
Can anyone tell me what wrong with these code or me? thanks
Sorry I’ve tried but still no avail; the code is below;
using UnityEngine.SceneManagement;
using System.Collections;
public class reload : MonoBehaviour{
void Update(){
if(Input.GetKeyDown(KeyCode.R)){
Scene scene = SceneManager.GetActiveScene(); SceneManager.LoadScene(scene.name);
}
}
}
The console saying the error is at fourth line, saying “The type or namespace name ‘MonoBehaviour’ could not be found (are you missing a using directive or an assembly reference)”