Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
再生モードが切り替わるタイミングでモデルを再生成する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