Ejemplo n.º 1
0
        /// <summary>
        /// Update the player spawn point to the opened level
        /// </summary>
        private void UpdatePlayerSpawnPoint()
        {
            var levelID = LevelSceneManagement.GetLoadedLevelID(_levelData);

            if (levelID == -1)
            {
                return;
            }

            var playerTransform = LevelSceneManagement.GetPlayerTransform();
            var respawnPosition =
                playerTransform == null ? Vector3.zero : playerTransform.position;

            _levelData.ModifyPlayerSpawnPoint(levelID, respawnPosition);
            serializedObject.ApplyModifiedProperties();

            SelectLevelItem(levelID);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Open the selected level scene
        /// </summary>
        private void OpenLevelScene(int index)
        {
            var curLevelID = LevelSceneManagement.GetLoadedLevelID(_levelData);

            LevelSceneManagement.OpenGamePlayScene();

            if (curLevelID == index)
            {
                Debug.Log("The specified level has been already opened");
                return;
            }

            // If user pressed cancel while asking for saving the scene,
            // not to load the new scene
            if (curLevelID != -1 &&
                !EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
            {
                return;
            }

            var sceneAssetPath = _levelData.GetLevelScenePath(index);

            LevelSceneManagement.OpenLevelScene(sceneAssetPath);
        }