/// <summary> /// Raises the playmode state change event. /// </summary> private static void OnPlaymodeStateChange() { // Change playmode enum currentPlaymode = PlaymodeState.Stopped; if (EditorApplication.isPaused) { currentPlaymode = PlaymodeState.Paused; } if (EditorApplication.isPlayingOrWillChangePlaymode) { currentPlaymode = PlaymodeState.AboutToPlay; } if (EditorApplication.isPlaying) { currentPlaymode = PlaymodeState.Playing; } // Fire on playmode state change event if (playmodeStateChanged != null) { playmodeStateChanged(currentPlaymode); } }
/// <summary> /// Initializes the static <see cref="Playmode"/> class. /// </summary> static Playmode() { currentPlaymode = PlaymodeState.Stopped; EditorApplication.playmodeStateChanged += OnPlaymodeStateChange; }