private void ExitScene(int sceneIdx = 0) { EntityManager entManager = World.Active.EntityManager; // end all jobs entManager.CompleteAllJobs(); // handle any scene exiting events if they exist if (OnSceneExit != null) { OnSceneExit(); } // delete all existing entites NativeArray <Entity> ents = entManager.GetAllEntities(); EntityCommandBuffer buffer = World.Active.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>() .CreateCommandBuffer(); foreach (Entity ent in ents) { buffer.DestroyEntity(ent); } ents.Dispose(); // reset for next scene instance = null; SceneManager.LoadScene(scenes[sceneIdx]); }
static public void GameOver() { gameOver = true; instance.gameoverPanel.SetActive(true); instance.sounds.PlayOneShot(instance.fanfares[1]); SceneSwapper.EnableLoading(); }
void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } }
// Start is called before the first frame update void Start() { God god = GameObject.Find("God").GetComponent <God>(); SceneSwapper sceneSwapper = GameObject.Find("SceneSwapper").GetComponent <SceneSwapper>(); foreach (BoardData boardData in god.gameData.boards) { GameObject newButton = Instantiate(button, transform); newButton.GetComponentInChildren <Text>().text = boardData.boardName; newButton.GetComponent <Button>().onClick.AddListener(delegate { god.SetCurrentBoard(newButton.transform.GetSiblingIndex()); }); newButton.GetComponent <Button>().onClick.AddListener(delegate { sceneSwapper.GoToScene("Board"); }); } }
void Awake() { //Check if there is already an instance of SoundManager if (Instance == null) { //if not, set it to this. Instance = this; } //If instance already exists: else if (Instance != this) { //Destroy this, this enforces our singleton pattern so there can only be one instance of SoundManager. Destroy(gameObject); } //Set SoundManager to DontDestroyOnLoad so that it won't be destroyed when reloading our scene. DontDestroyOnLoad(gameObject); }
private void Start() { sceneSwap = GetComponent <SceneSwapper>(); }
void Start() { instance = this; sounds = GetComponent <AudioSource>(); }
// Start is called before the first frame update void Start() { DontDestroyOnLoad(this.gameObject); gameData = SaveSystem.LoadGame(); ss = GameObject.Find("SceneSwapper").GetComponent <SceneSwapper>(); }
// Start is called before the first frame update void Start() { god = GameObject.Find("God").GetComponent <God>(); ss = GameObject.Find("SceneSwapper").GetComponent <SceneSwapper>(); }