Skip to content

Instantly share code, notes, and snippets.

@tarob19
Last active March 1, 2016 09:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarob19/6a2f387a3a1fbde4dfa6 to your computer and use it in GitHub Desktop.
Save tarob19/6a2f387a3a1fbde4dfa6 to your computer and use it in GitHub Desktop.
再生モードが切り替わるタイミングでモデルを再生成するWindow
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