internal void LoadLevel(int indexOffset) { BasePhysicsDemo.ResetDefaultWorld(); var i = m_SceneData.FindIndex(s => s.Index == SceneManager.GetActiveScene().buildIndex); i += indexOffset; i = (i % m_SceneData.Count + m_SceneData.Count) % m_SceneData.Count; SceneManager.LoadScene(m_SceneData[i].Index, LoadSceneMode.Single); }
#pragma warning restore 649 void Start() { DontDestroyOnLoad(m_EventSystem); DontDestroyOnLoad(gameObject); m_MenuButton.onClick.AddListener(() => { BasePhysicsDemo.ResetDefaultWorld(); SceneManager.LoadScene(0, LoadSceneMode.Single); Destroy(gameObject); Destroy(m_EventSystem.gameObject); }); m_PreviousButton.onClick.AddListener(() => { Loader.LoadLevel(-1); }); m_NextButton.onClick.AddListener(() => { Loader.LoadLevel(1); }); m_ReloadButton.onClick.AddListener(() => { Loader.LoadLevel(0); }); OnSceneLoaded(SceneManager.GetActiveScene(), default); SceneManager.sceneLoaded += OnSceneLoaded; }