private void Update() { Debug.Log($"被调用前的值为: {sceneData.GetCurrentIndex()}"); if (currentSceneIndex != sceneData.GetCurrentIndex()) { SceneManager.LoadSceneAsync(sceneData.GetCurrentIndex()); currentSceneIndex = sceneData.GetCurrentIndex(); } }
private void Start() { SceneData sceneData = new SceneData(); sceneData.setValue(SceneManager.GetActiveScene().buildIndex, SceneManager.sceneCountInBuildSettings, SceneManager.GetActiveScene().name); currentSceneIndex = sceneData.GetCurrentIndex(); }