| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using UnityEditor;
- using UnityEditor.SceneManagement;
- using UnityEngine;
- namespace TowerDevil.Editor
- {
- [InitializeOnLoad]
- static class NightFourPreview
- {
- const string ReviewFlag = "TowerDevil.PreviewNightFour";
- static NightFourPreview()
- {
- EditorApplication.playModeStateChanged += state =>
- {
- if (state == PlayModeStateChange.EnteredPlayMode && SessionState.GetBool(ReviewFlag, false))
- {
- SessionState.EraseBool(ReviewFlag);
- EditorApplication.delayCall += Show;
- }
- };
- }
- [MenuItem("Tools/Tower Devil/Play Night 4")]
- static void Play()
- {
- if (EditorApplication.isPlaying)
- {
- Show();
- return;
- }
- if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
- return;
- EditorSceneManager.OpenScene("Assets/TowerDevil/Scenes/TowerDevil.unity");
- SessionState.SetBool(ReviewFlag, true);
- EditorApplication.isPlaying = true;
- }
- static void Show()
- {
- var game = Object.FindFirstObjectByType<TowerGame>();
- if (game != null)
- game.EditorReview();
- }
- }
- }
|