Last active
March 1, 2016 09:12
-
-
Save tarob19/6a2f387a3a1fbde4dfa6 to your computer and use it in GitHub Desktop.
再生モードが切り替わるタイミングでモデルを再生成するWindow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StateTest : EditorWindow | |
{ | |
[MenuItem ("Window/Test")] | |
public static void Open () | |
{ | |
EditorWindow.GetWindow<StateTest> ("Test").Show (); | |
} | |
private bool _updated = false; | |
void OnEnable () | |
{ | |
EditorApplication.playmodeStateChanged += OnPlayModeStateChanged; | |
} | |
void OnDisable () | |
{ | |
EditorApplication.playmodeStateChanged -= OnPlayModeStateChanged; | |
} | |
void OnPlayModeStateChanged () | |
{ | |
if (EditorApplication.isPlaying == EditorApplication.isPlayingOrWillChangePlaymode) { | |
// pause対応 | |
if (_updated == false) { | |
CreateModel (); | |
_updated = true; | |
} | |
} else { | |
DestroyModel (); | |
_updated = false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment