void OnValidate() { if (PrefabStageUtility.GetCurrentPrefabStage() != null || PrefabUtility.IsPartOfPrefabAsset(this)) { id = 0; } else { var scene = SceneManager.GetActiveScene(); SceneIds idsInScene = null; if (!state.TryGetValue(scene, out idsInScene)) { state[scene] = idsInScene = new SceneIds(); } if (id == 0 || !idsInScene.tryClaimId(id)) { id = idsInScene.getUnclaimedId(); } // NOTE once an ID is claimed, if the object ever tries to get a different ID, the original ID is not freed. // This should be ok since state is often reset in the editor. // Once all objects in a scene have unique IDs, those IDs are serialized and a reload will allow them all to claim their IDs. // Only when new objects are added, or when existing objects are copy-pasted, will collisions be detected // and one of the object's ID will change. } }
public static void SwitchToMenu(SceneIds id, Object o) { if (id == SceneIds.Game) { m_InMenu = false; GameScene gs = new GameScene(m_GameView, (InputGameInfo)o); m_GameView.Director.ReplaceScene(gs); gs.StartGame(); return; } m_InMenu = true; CCScene scene = new CCScene(m_GameView); if (id == SceneIds.OpeningMenu) { scene.AddLayer(new BackgroundLayer("achtergrond1")); scene.AddLayer(m_CurrentMenu = new OpeningMenu()); } if (id == SceneIds.PlayMenu) { scene.AddLayer(new BackgroundLayer("achtergrond1")); if (o == null) { scene.AddLayer(m_CurrentMenu = new PlayMenu()); } else { scene.AddLayer(m_CurrentMenu = new PlayMenu((List <InputPlayer>)o)); } } if (id == SceneIds.HelpMenu) { scene.AddLayer(new BackgroundLayer("achtergrond1")); scene.AddLayer(m_CurrentMenu = new HelpMenu()); } if (id == SceneIds.SettingsMenu) { scene.AddLayer(new BackgroundLayer("achtergrond1")); scene.AddLayer(m_CurrentMenu = new SettingMenu()); } m_GameView.Director.ReplaceScene(scene); }
internal void GoToScene(SceneIds sceneId) { CurrentScene = sceneId; switch (sceneId) { case SceneIds.HomeScene: SceneManager.LoadScene("HomeScene"); break; case SceneIds.GameScene: SceneManager.LoadScene("SampleScene"); break; } if (IsGamePaused) { PauseGame(false); } }
public void ChangeScene(SceneIds scene) { if (scene == SceneStep) { SceneRepeatTimes++; } else { SceneRepeatTimes = 0; } SceneStep = scene; //Main.NewText("Scene: " + scene.ToString()); if (MessageTime > 0) { StepTime = MessageTime + 30; } else { StepTime = 300; } }