I had a few questions regarding creating a LevelManager object.
So I tried making my LevelManager private instead of public/drag and drop method, because my understanding was that since both scripts are in the same folder and I am just creating a LevelManager object why can’t I use
private LevelManager level;
level.loadLevel(“Lose”);
You can do that, you simply need to add a line to find your level manager in the scene:
private LevelManager level;
private void Start() {
level = GameObject.FindObjectOfType<LevelManager>();
}
level.loadLevel(“Lose”);
Alternatively, you could create a LevelManager class that does not derive from MonoBehaviour and is not attached to a game object in your scene, in which case you need to instantiate it using the new keyword:
private LevelManager level = new LevelManager();
level.loadLevel(“Lose”);