void OnPlayModeChanged(PlayModeState currentMode, PlayModeState changedMode) { // Debug.Log(currentMode.ToString() + " => " + changedMode.ToString()); if (currentMode == PlayModeState.Stopped && changedMode == PlayModeState.Playing) { } if (currentMode == PlayModeState.Playing && changedMode == PlayModeState.Paused) { //Pause in editor _applicationPause_pause = IsPaused(); _applicationPause_playing = IsPlaying(); Pause(); } if (currentMode == PlayModeState.Paused && changedMode == PlayModeState.Playing) { //Resume in editor if (_applicationPause_pause) { // Pause(); } else if (_applicationPause_playing) { Play(); } } }
private static void OnPlayModeStateChanged(PlayModeState playModeState) { if (playModeState == PlayModeState.ExitingPlayMode) { InjectFor_CurrentScene(); } }
/// <summary> /// Unity callback called when playmode changes. /// Un-/Registered in the OnDisable/OnEnable. /// Updates the m_PlayModeState member and the activeParent. /// Creates or destroy the guiCallback. /// </summary> void OnPlaymodeChange() { // Update playmode if (EditorApplication.isPlaying) { m_PlayModeState = !EditorApplication.isPlayingOrWillChangePlaymode ? PlayModeState.SwitchingToEditor : PlayModeState.Playing; } else { m_PlayModeState = EditorApplication.isPlayingOrWillChangePlaymode ? PlayModeState.SwitchingToPlaymode : PlayModeState.Editor; } // if (/*!EditorApplication.isPaused &&*/ (EditorApplication.isPlayingOrWillChangePlaymode && EditorApplication.isPlaying || !EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPlaying)) { if (m_PlayModeState == PlayModeState.Playing || m_PlayModeState == PlayModeState.Editor) { var parentID = m_SerializedParentID; activeParent = null; activeParent = EditorUtility.InstanceIDToObject(parentID) as ParentBehaviour; GUIUtility.hotControl = 0; GUIUtility.keyboardControl = 0; } // Create guiCallback? if (m_PlayModeState == PlayModeState.SwitchingToEditor && m_GUICallback == null) { m_GUICallback = this.CreateGUICallback(); } // Destroy guiCallback? else if (m_PlayModeState == PlayModeState.SwitchingToPlaymode && m_GUICallback != null) { DestroyImmediate(m_GUICallback.gameObject, true); } }
private void OnPlayModeChanged(PlayModeState currentState, PlayModeState changedState) { if (PlayModeChanged != null) { PlayModeChanged(currentState, changedState); } }
private static void OnPlayModeChanged(PlayModeState oldState, PlayModeState newState) { if (PlayModeChanged != null) { PlayModeChanged(oldState, newState); } }
private static void OnPlayModeChanged(PlayModeState currentMode, PlayModeState changedMode) { //Debug.Log("play mode changed"); if (changedMode == PlayModeState.AboutToPlay) { PackedSpriteGroupEditor.AggregateAllAtlases(); } }
static EditorPlayMode() { EditorApplication.playmodeStateChanged = OnUnityPlayModeChanged; if (EditorApplication.isPaused) { _currentState = PlayModeState.Paused; } }
internal void InvokePlayModeStateChanged(PlayModeState playModeState, PlayModeStateEvent e) { if (e == null) { return; } e.Invoke(playModeState); }
private static void OnPlayModeChanged(PlayModeState currentState, PlayModeState changedState) { if (changedState == PlayModeState.Stopped || (changedState == PlayModeState.Playing && currentState == PlayModeState.Stopped)) { //if (LuaManagerStatus.LuaManagerInited) // LuaManager.Clear(); } }
public static void OnPlayModeStateChanged(PlayModeState currentMode, PlayModeState changedMode) { if (currentMode == PlayModeState.Stopped && changedMode == PlayModeState.Playing || currentMode == PlayModeState.AboutToPlay && changedMode == PlayModeState.Playing) { AirConsole controller = GameObject.FindObjectOfType <AirConsole>(); OpenBrowser(controller, Application.dataPath + Settings.WEBTEMPLATE_PATH); } }
private static void OnUnityPlayModeChanged(PlayModeStateChange playModeStateChange) { var newState = GetPlayModeState; // Fire PlayModeChanged event. OnPlayModeChanged(_oldState, newState); // Set current state. _oldState = newState; }
public static void OnPlayModeStateChanged(PlayModeState currentMode, PlayModeState changedMode) { if (currentMode == PlayModeState.Stopped && changedMode == PlayModeState.Playing || currentMode == PlayModeState.AboutToPlay && changedMode == PlayModeState.Playing) { AirConsole controller = GameObject.FindObjectOfType<AirConsole>(); OpenBrowser(controller, Application.dataPath + Settings.WEBTEMPLATE_PATH); } }
static EditorPlayMode() { #if UNITY_EDITOR EditorApplication.playmodeStateChanged = OnUnityPlayModeChanged; if (EditorApplication.isPaused) { _currentState = PlayModeState.Paused; } #endif }
private static void OnPlayModeChanged(PlayModeState oldState, PlayModeState newState) { if (newState == oldState || !isEnabled) { return; } ActiveLayoutSelection.Clear(); TheIndex = -1; AddLayoutsOfCurrentModeToActive(); EditorApplication.ExecuteMenuItem("Window/Layouts/Smart Layout/Quick Switch %l"); }
private static void OnUnityPlayModeChanged() { var changedState = PlayModeState.Stopped; int state = GetEditorAppStateBoolComb(); switch (state) { case (22112): changedState = PlayModeState.Playing; break; case (21112): changedState = PlayModeState.Paused; break; case (22222): changedState = PlayModeState.Stopped; break; case (22122): changedState = PlayModeState.AboutToStop; break; case (21122): changedState = PlayModeState.AboutToStop; break; case (21222): changedState = PlayModeState.Stopped; break; case 22212: changedState = PlayModeState.Stopped; break; case 21212: changedState = PlayModeState.Paused; break; default: // Debug.Log("No such state combination defined: " + state); break; } // Fire PlayModeChanged event. if (_currentState != changedState) { OnPlayModeChanged(_currentState, changedState); } // Set current state. _currentState = changedState; }
private static void OnUnityPlayModeChanged() { var changedState = PlayModeState.Stopped; switch (_currentState) { case PlayModeState.Stopped: if (EditorApplication.isPlayingOrWillChangePlaymode) { changedState = PlayModeState.Playing; } else if (EditorApplication.isPaused) { changedState = PlayModeState.Paused; } break; case PlayModeState.Playing: if (EditorApplication.isPaused) { changedState = PlayModeState.Paused; } else if (EditorApplication.isPlaying) { changedState = PlayModeState.Playing; } else { changedState = PlayModeState.Stopped; } break; case PlayModeState.Paused: if (EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPaused) { changedState = PlayModeState.Playing; } else if (EditorApplication.isPlayingOrWillChangePlaymode && EditorApplication.isPaused) { changedState = PlayModeState.Paused; } break; default: return; } // Set current state. _currentState = changedState; }
/// <summary> /// A Unity callback called when the window is loaded. /// </summary> void OnEnable() { // Set window name this.name = Print.GetLogo() + " Behaviour"; // Update singleton instance Instance = this; // Update NotVisible value BehaviourWindow.s_NotVisible = this.m_NotVisible; // Set playmode state if (m_PlayModeState == PlayModeState.Unknow) { m_PlayModeState = EditorApplication.isPlaying ? PlayModeState.Playing : PlayModeState.Editor; // The guiCallback is null and the unity application is not playing or changing playmode? if (m_GUICallback == null && !EditorApplication.isPlayingOrWillChangePlaymode) { // Create game object GameObject go = EditorUtility.CreateGameObjectWithHideFlags("GUI Object", HideFlags.HideAndDontSave, new System.Type[] { typeof(GUICallback) }); // Get GUICallback component m_GUICallback = go.GetComponent <GUICallback>(); } } // Set callbacks activeParentChanged += OnParentSelectionChange; activeNodeChanged += OnNodeSelectionChange; EditorApplication.playmodeStateChanged += OnPlaymodeChange; EditorApplication.delayCall += OnDelayCall; LoadSceneUtility.onLoadScene += this.OnLoadScene; BehaviourMachinePrefs.preferencesChanged += this.Repaint; // The minimum size of this window base.minSize = new Vector2(200f, 150f); // Forces selection update activeParent = EditorUtility.InstanceIDToObject(m_SerializedParentID) as ParentBehaviour; OnSelectionChange(); activeNodeID = m_SerializedNodeID; // Set guiController SetParentGUI(); // Automatically repaint window whenever the scene has change base.autoRepaintOnSceneChange = true; }
private static void SetupAssemblyReloadEvents() { // Unity supports recompile/reload settings natively for Unity 2018.2+ if (UnityUtils.UnityVersion >= new Version(2018, 2)) { return; } // playmodeStateChanged was marked obsolete in 2017.1. Still working in 2018.3 #pragma warning disable 618 EditorApplication.playmodeStateChanged += () => #pragma warning restore 618 { if (PluginSettings.AssemblyReloadSettings == ScriptCompilationDuringPlay.RecompileAfterFinishedPlaying) { MainThreadDispatcher.Instance.Queue(() => { var newPlayModeState = GetPlayModeState(); if (PlayModeSavedState != newPlayModeState) { if (newPlayModeState == PlayModeState.Playing) { ourLogger.Info("LockReloadAssemblies"); EditorApplication.LockReloadAssemblies(); } else if (newPlayModeState == PlayModeState.Stopped) { ourLogger.Info("UnlockReloadAssemblies"); EditorApplication.UnlockReloadAssemblies(); } PlayModeSavedState = newPlayModeState; } }); } }; AppDomain.CurrentDomain.DomainUnload += (sender, args) => { if (PluginSettings.AssemblyReloadSettings == ScriptCompilationDuringPlay.StopPlayingAndRecompile) { if (EditorApplication.isPlaying) { EditorApplication.isPlaying = false; } } }; }
private void OnUnityPlayModeChanged() { var changedState = PlayModeState.Stopped; switch (_currentState) { case PlayModeState.Stopped: if (EditorApplication.isPlayingOrWillChangePlaymode) { changedState = PlayModeState.Playing; } break; case PlayModeState.Playing: if (EditorApplication.isPaused) { changedState = PlayModeState.Paused; } else { changedState = PlayModeState.Stopped; } break; case PlayModeState.Paused: if (EditorApplication.isPlayingOrWillChangePlaymode) { changedState = PlayModeState.Playing; } else { changedState = PlayModeState.Stopped; } break; default: throw new System.ArgumentOutOfRangeException(); } // Fire PlayModeChanged event. OnPlayModeChanged(_currentState, changedState); // Set current state. _currentState = changedState; }
public void OnUnityPlayModeChanged() { var changedState = PlayModeState.Stopped; switch (_currentState) { case PlayModeState.Stopped: if (EditorApplication.isPlayingOrWillChangePlaymode) { changedState = PlayModeState.Playing; } break; case PlayModeState.Playing: if (EditorApplication.isPaused) { changedState = PlayModeState.Paused; } else { changedState = PlayModeState.Stopped; } break; case PlayModeState.Paused: if (EditorApplication.isPlayingOrWillChangePlaymode) { changedState = PlayModeState.Playing; } else { changedState = PlayModeState.Stopped; } break; } _currentState = changedState; if (_currentState == PlayModeState.Stopped) { EditorApplication.OpenScene(PlayerPrefs.GetString("TestScene")); } }
private static void OnUnityPlayModeChanged() { var changedState = PlayModeState.Stopped; int state = GetEditorAppStateBoolComb(); switch (state) { case (22112): changedState = PlayModeState.Playing; break; case (21112): changedState = PlayModeState.Paused; break; case (22222): changedState = PlayModeState.Stopped; break; case (22122): changedState = PlayModeState.AboutToStop; break; case (21122): changedState = PlayModeState.AboutToStop; break; case (21222): changedState = PlayModeState.Stopped; break; case 22212: changedState = PlayModeState.Stopped; break; case 21212: changedState = PlayModeState.Paused; break; default: // Debug.Log("No such state combination defined: " + state); break; } // Fire PlayModeChanged event. if (_currentState != changedState) OnPlayModeChanged(_currentState, changedState); // Set current state. _currentState = changedState; }
private static void OnPlayModeChanged(PlayModeState currentMode, PlayModeState changedMode) { // DO your stuff here... if (changedMode == PlayModeState.AboutToStop || changedMode == PlayModeState.Stopped) { TimelineCode.running = false; } //if (changedMode == PlayModeState.Playing) //TimelineCode.running = true; TimelineCode.Log(currentMode.ToString() + " => " + changedMode.ToString()); if (debugOp) { TimelineCode.Log(EditorApplication.isCompiling); TimelineCode.Log(EditorApplication.isPaused); TimelineCode.Log(EditorApplication.isPlaying); TimelineCode.Log(EditorApplication.isPlayingOrWillChangePlaymode); TimelineCode.Log(EditorApplication.isUpdating); Debug.LogWarning("-------------------------------------"); } }
private static void SetupAssemblyReloadEvents() { // playmodeStateChanged was marked obsolete in 2017.1. Still working in 2018.3 #pragma warning disable 618 EditorApplication.playmodeStateChanged += () => #pragma warning restore 618 { var newPlayModeState = GetPlayModeState(); if (PlayModeSavedState != newPlayModeState) { if (PluginSettings.AssemblyReloadSettings == AssemblyReloadSettings.RecompileAfterFinishedPlaying) { if (newPlayModeState == PlayModeState.Playing) { ourLogger.Info("LockReloadAssemblies"); EditorApplication.LockReloadAssemblies(); } else if (newPlayModeState == PlayModeState.Stopped) { ourLogger.Info("UnlockReloadAssemblies"); EditorApplication.UnlockReloadAssemblies(); } } PlayModeSavedState = newPlayModeState; } }; AppDomain.CurrentDomain.DomainUnload += (sender, args) => { if (PluginSettings.AssemblyReloadSettings == AssemblyReloadSettings.StopPlayingAndRecompile) { if (EditorApplication.isPlaying) { EditorApplication.isPlaying = false; } } }; }
/// <summary> /// Unity callback called when playmode changes. /// Un-/Registered in the OnDisable/OnEnable. /// Updates the m_PlayModeState member and the activeParent. /// Creates or destroy the guiCallback. /// </summary> void OnPlaymodeChange () { // Update playmode if (EditorApplication.isPlaying) m_PlayModeState = !EditorApplication.isPlayingOrWillChangePlaymode ? PlayModeState.SwitchingToEditor : PlayModeState.Playing; else m_PlayModeState = EditorApplication.isPlayingOrWillChangePlaymode ? PlayModeState.SwitchingToPlaymode : PlayModeState.Editor; // if (/*!EditorApplication.isPaused &&*/ (EditorApplication.isPlayingOrWillChangePlaymode && EditorApplication.isPlaying || !EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPlaying)) { if (m_PlayModeState == PlayModeState.Playing || m_PlayModeState == PlayModeState.Editor) { var parentID = m_SerializedParentID; activeParent = null; activeParent = EditorUtility.InstanceIDToObject(parentID) as ParentBehaviour; GUIUtility.hotControl = 0; GUIUtility.keyboardControl = 0; } // Create guiCallback? if (m_PlayModeState == PlayModeState.SwitchingToEditor && m_GUICallback == null) { m_GUICallback = this.CreateGUICallback(); } // Destroy guiCallback? else if (m_PlayModeState == PlayModeState.SwitchingToPlaymode && m_GUICallback != null) { DestroyImmediate(m_GUICallback.gameObject, true); } }
/// <summary> /// A Unity callback called when the window is loaded. /// </summary> void OnEnable () { // Set window name this.name = Print.GetLogo() + " Behaviour"; // Update singleton instance Instance = this; // Update NotVisible value BehaviourWindow.s_NotVisible = this.m_NotVisible; // Set playmode state if (m_PlayModeState == PlayModeState.Unknow) { m_PlayModeState = EditorApplication.isPlaying ? PlayModeState.Playing : PlayModeState.Editor; // The guiCallback is null and the unity application is not playing or changing playmode? if (m_GUICallback == null && !EditorApplication.isPlayingOrWillChangePlaymode) { // Create game object GameObject go = EditorUtility.CreateGameObjectWithHideFlags("GUI Object", HideFlags.HideAndDontSave, new System.Type[] {typeof(GUICallback)}); // Get GUICallback component m_GUICallback = go.GetComponent<GUICallback>(); } } // Set callbacks activeParentChanged += OnParentSelectionChange; activeNodeChanged += OnNodeSelectionChange; EditorApplication.playmodeStateChanged += OnPlaymodeChange; EditorApplication.delayCall += OnDelayCall; LoadSceneUtility.onLoadScene += this.OnLoadScene; BehaviourMachinePrefs.preferencesChanged += this.Repaint; // The minimum size of this window base.minSize = new Vector2(200f, 150f); // Forces selection update activeParent = EditorUtility.InstanceIDToObject(m_SerializedParentID) as ParentBehaviour; OnSelectionChange(); activeNodeID = m_SerializedNodeID; // Set guiController SetParentGUI(); // Automatically repaint window whenever the scene has change base.autoRepaintOnSceneChange = true; }
private void OnEnable() { state = (PlayModeState)EditorPrefs.GetInt("PI.PlayModeState", (int)PlayModeState.EditMode); }
public virtual void OnPlaymodeStateChanged(PlayModeState playModeState) { }
static PlayMode() { EditorApplication.playmodeStateChanged = OnUnityPlayModeChanged; if (EditorApplication.isPaused) _currentState = PlayModeState.Paused; }
public override void OnPlaymodeStateChanged(PlayModeState playModeState) { //Debug.Log ("游戏运行模式发生改变, 点击 运行游戏 或者暂停游戏或者 帧运行游戏 按钮时触发: " + playModeState); }
private static void OnPlayModeChanged(PlayModeState currentState, PlayModeState changedState) { if (PlayModeChanged != null) PlayModeChanged(currentState, changedState); }
private static void OnUnityPlayModeChanged() { var changedState = PlayModeState.Stopped; //Stoped -> Playing : 22112 //playing -> abouttostop : 22122 //about2stop -> stopped : 22222 //playing -> paused : 21112 //paused -> playing : 22112 //paused -> abouttostop : 21122 //stoped -> paused in editor (stoped) : 21222 //editor paused - > play(paused) : 21112 //stoped -> abouttoplay in editor: 22212 //editor paused -> play : 21212 //paused anyway int state = GetEditorAppStateBoolComb(); switch (state) { case (22112): changedState = PlayModeState.Playing; break; case (21112): changedState = PlayModeState.Paused; break; case (22222): changedState = PlayModeState.Stopped; break; case (22122): changedState = PlayModeState.AboutToStop; break; case (21122): changedState = PlayModeState.AboutToStop; break; case (21222): changedState = PlayModeState.Stopped; break; case 22212: changedState = PlayModeState.Stopped; break; case 21212: changedState = PlayModeState.Paused; break; default: throw new SystemException("No such state combination defined: " + state); } // Fire PlayModeChanged event. if (_currentState != changedState) { OnPlayModeChanged(_currentState, changedState); } // Set current state. _currentState = changedState; }
private static void OnUnityPlayModeChanged() { var changedState = PlayModeState.Stopped; //Stoped -> Playing : 22112 //playing -> abouttostop : 22122 //about2stop -> stopped : 22222 //playing -> paused : 21112 //paused -> playing : 22112 //paused -> abouttostop : 21122 //stoped -> paused in editor (stoped) : 21222 //editor paused - > play(paused) : 21112 //stoped -> abouttoplay in editor: 22212 //editor paused -> play : 21212 //paused anyway int state2 = GetEditorAppStateBoolComb2(); // Debug.Log("state2:"+state2); switch (state2) { case (6): changedState = PlayModeState.Playing; break; case (14): case (10): changedState = PlayModeState.Paused; break; case (0): case (2): case (8): changedState = PlayModeState.Stopped; break; case (4): case (12): changedState = PlayModeState.AboutToStop; break; // default: // throw new SystemException("No such state combination defined: " + state2); } /* * int state = GetEditorAppStateBoolComb(); * Debug.Log("stater:" + state); * switch (state) { * case (22112): * changedState = PlayModeState.Playing; * break; * case (21112): * changedState = PlayModeState.Paused; * break; * case (22222): * changedState = PlayModeState.Stopped; * break; * case (22122): * changedState = PlayModeState.AboutToStop; * break; * case (21122): * changedState = PlayModeState.AboutToStop; * break; * case (21222): * changedState = PlayModeState.Stopped; * break; * case 22212: * changedState = PlayModeState.Stopped; * break; * case 21212: * changedState = PlayModeState.Paused; * break; * default: * throw new SystemException("No such state combination defined: "+state); * } */ // Fire PlayModeChanged event. if (_currentState != changedState) { OnPlayModeChanged(_currentState, changedState); } // Set current state. _currentState = changedState; }