I built 2D board game on unity and I want to make it possible for the player to restart the game at any time (all I need to do is reset all the variables to their initial values and bring the stones to the original position). I don’t know why, but Application.LoadLevel() with the same scene as before (I have only this scene) won’t work for me. It does bring the stones to the original position, but I get a NullReferenceException whenever I try to play the game after restarting it.
The script I am using is as follows:
using UnityEngine;
using System.Collections;
public class ResetGame : MonoBehaviour
{
void OnEnable()
{
Application.LoadLevel ("Madelinette");
}
}
Any idea about what is causing the problem?
Thanks for any help.