public void LoadLevel(String levelName, String newLevelName) { allowWorker = false; if (thread != null) { thread.Abort(); } Hashtable sceneArguments = new Hashtable(); lock (passiveSystemManagers) { if (levelName != null) { //Debug.LogWarning("levelName="+levelName); PassiveSystemManager psmToHold = passiveSystemManagers.Where(i => i.name.Equals(levelName)).FirstOrDefault(); if (psmToHold != null) { //if(psmToHold.isActive) { passiveSystemManagers.ElementAt(psmToHold.index).isActive = false; psmToHold.isActive = false; foreach (PassiveSystemManager item in passiveSystemManagers) { if (item.name.Equals(levelName)) { item.isActive = false; break; } } //Debug.LogWarning("!!!Add "+levelName+" to background, psm[0] is active = " + passiveSystemManagers[0].isActive); //} } } PassiveSystemManager psmToStart = passiveSystemManagers.Where(i => i.name.Equals(newLevelName)).FirstOrDefault(); if (psmToStart != null) { if (!psmToStart.isActive) { psmToStart.isActive = true; Debug.LogWarning("!!!Add " + newLevelName + " to foreground"); } if (psmToStart.shipsList != null && psmToStart.shipsList.Count > 0) { sceneArguments.Add("Ships", psmToStart.shipsList); } } } SceneManager.LoadScene(newLevelName, sceneArguments); allowWorker = true; if (thread != null) { StartBackThread(); } }
public GlobalManager() { PassiveSystemManager system1 = new PassiveSystemManager("System1"); PassiveSystemManager system2 = new PassiveSystemManager("System2"); PassiveSystemManager system3 = new PassiveSystemManager("System3"); system1.index = 0; system2.index = 1; system3.index = 2; passiveSystemManagers.Add(system1); passiveSystemManagers.Add(system2); passiveSystemManagers.Add(system3); }