To make sure you only have one ScoreManager at all times, add these lines to the top of your ScoreManager's Awake
method.
if (instance != null)
{
Destroy(gameObject);
return;
}
This is commonly known in software development as the singleton pattern.
Application.Quit();
when you want to close the game
Script Reference: SceneManager.sceneLoaded
// called first
void OnEnable()
{
Debug.Log("OnEnable called");
SceneManager.sceneLoaded += OnSceneLoaded;
}
// called second
void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
Debug.Log("OnSceneLoaded: " + scene.name);
Debug.Log(mode);
}
string [] files = System.IO.Directory.GetFiles(path);
foreach (string file in files)
{
//Do work on the files here
}
.EndsWith(".unity")
Application.datapath
tells the root of Assets pathGameManager