private static void OnUpdate() { if (levelToOpen == null || EditorApplication.isPlaying || EditorApplication.isPaused || EditorApplication.isCompiling || EditorApplication.isPlayingOrWillChangePlaymode) { return; } switch (pass) { case Pass.First: player.level = levelToOpen; Selection.activeTransform = Object.FindObjectOfType <Mobge.TemporaryEditorObjects>().transform; Mobge.UnityExtensions.DestroySelf(Mobge.TemporaryEditorObjects.Shared.gameObject); pass = Pass.Second; break; case Pass.Second: EditorApplication.update -= OnUpdate; Selection.activeTransform = player.transform; levelToOpen = null; break; } }
public static void SelecLevel(string levelPath) { if (player == null) { player = Object.FindObjectOfType <Mobge.Microns.MicronLevelPlayer>(); } if (EditorApplication.isPlaying) { EditorApplication.isPlaying = false; } levelToOpen = (Mobge.BrigRex.Level)AssetDatabase.LoadAssetAtPath(levelPath, typeof(Mobge.BrigRex.Level)); UnityEngine.Assertions.Assert.IsNotNull(levelToOpen, "Level file does not exist at : " + levelPath); pass = Pass.First; EditorApplication.update += OnUpdate; }