0 votes
by (8.2k points)

I want a button that will reset all the objects to the initial state. This error I'm trying to make an AR-based game In which I can use gravity to move the ball Navigate the maze and reach the win area By moving the Cube Right now I can't get the ball to move the way I want that's why I tried adding a reset button so the ball is on the plane (image target) ball is a rigid body and I added colliders to everything. But it's not working the way I hoped.
The type or namespace name 'SceneManagment' does not exist In the namespace 'UnityEngine' (are you missing an assemble reference)

 

1 Answer

0 votes
by (8.2k points)
  1. For reloading scene, write following line in method and attach it to respective button SceneManager.LoadScene(SceneManager.GetActiveScene());
  2. Create a function in a script, write this line of code in it, and on your button "OnClick" call this function.
  3. Check the spelling of Management in line number 4.

    using System. Collections;

    using System. Collections.Generic;

    using UnityEngine;

    using UnityEngine.SceneManagement;

    public class ResetButton : MonoBehaviour

    {

        public void RestartTheGame()

        {

            SceneManager.LoadScene(SceneManager.GetActiveScene());

        }    

    }
     

  4. Replace line number 
    SceneManager.LoadScene(SceneManager.GetActiveScene()); with. SceneManager.LoadScene(SceneManager.GetActiveScene().name);

    using System. Collections;
    using System. Collections.Generic;
    using UnityEngine;
    using UnityEngine.SceneManagement;
    public class ResetButton : MonoBehaviour
    {
        public void RestartTheGame()
        {
          SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        }    
    }

TechXR runs courses in AR / VR / Metaverse / Game Development. Some of the popular Q&A in our courses are available here for easy discovery.

113 questions

117 answers

8 comments

99.7k users

...