public void DoIt(string msg, Action nextAction) { //debug Debug.LogWarning(" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); Debug.LogWarning("+++ NEW ACTION " + nextAction.ToString() + " :" + msg); DoActionMgr action = new DoActionMgr(); action.showmessage = msg;// " restart..."; action.frameskip = 3; //action.timeskip_marktime = (float)EditorApplication.timeSinceStartup; action.nextAction = nextAction; //next_action = action; next_action_List.Add(action); }
void OnGUI() { //Debug.LogWarning("left shift: "+ Input.GetKey(KeyCode.LeftShift)); if (!initialized) { initialized = true; int newvalue2 = PlayerPrefs.GetInt("autoRunDisable"); //Debug.LogWarning(" --------------------------------------------------------------"); //Debug.LogWarning(" init... autoRunDisable=" + newvalue2); if (newvalue2 == 1) { autoRunDisable = true; } else { autoRunDisable = false; } } //EditorGUILayout.LabelField("Compiling:", EditorApplication.isCompiling ? "Yes" : "No"); float time = (float)EditorApplication.timeSinceStartup; //this.Repaint(); var isCompiling = EditorApplication.isCompiling; if (STOP_ONCE) { STOP_ONCE = false; // just stop if (CompileWindow.instance != null) { CompileWindow.instance.DoIt(" just stop...", Action.action_stop); } } //--------------------------------------------- // Compiling... started.... finished... //--------------------------------------------- //--------------------------------------------- if (EditorApplication.isCompiling != _compiling) { _compiling = isCompiling; if (_compiling) { //Debug.LogWarning(">>> >>> >>> compiling started..."); ShowToast("compiling started..."); } else { //Debug.LogWarning(">>> >>> >>> compiling finished..."); ShowToast("compiling finished..."); _pending_startPlay = true; } } //--------------------------------------------- //--------------------------------------------- //EditorGUILayout.LabelField(isCompiling ? "Yes" : "No"); float totalProgTime = 0.15f; float t = 0f;// 0.5f; if (frame_counter > 0) { frame_counter--; marktime = (float)EditorApplication.timeSinceStartup; //Debug.Log(" reset marktime... " + frame_counter); if (frame_counter == 0) { if (_pending_startPlay == true) { _pending_startPlay = false; // next action if (!CompileWindow.instance.autoRunDisable) { if (CompileWindow.instance != null) { CompileWindow.instance.DoIt(" play...", Action.action_just_play); } } } } } if (marktime > 0) { t = (time - marktime); } if (t > totalProgTime)//0.25f) { marktime = 0f; msg = ""; } DoActionMgr action = null;// = next_action; if (next_action_List.Count > 0) { action = next_action_List[0]; } if (t > 0 || isCompiling || action != null)//isCompiling)//progress < secs) { title8 = "status..."; if (isCompiling) { title8 = "Compiling..."; message = "Compiling..." + msg; } else { if (action != null) { message = msg + ";" + action.nextAction; } else { message = msg + " {msg}"; } if (!string.IsNullOrEmpty(msg3)) { message = message + "; [" + msg3 + "]"; } } //else //{ // title = "status..."; // message = msg; // //message = "Compiling progress..."; //} //if (current_state == PlayModeStateChange.ExitingPlayMode) // t2 = (1.0f - t) / 10f; //else t2 = t / totalProgTime;// 0.25f; //if (isCompiling) // t = 0.5f; //if (isCompiling) // t2 = 0.5f + t2; //if (current_state == PlayModeStateChange.ExitingEditMode) // t2 = 0.7f + t2; //if (current_state == PlayModeStateChange.EnteredPlayMode) // t2 = 0.9f + t2; //if (current_state == PlayModeStateChange.ExitingPlayMode) // t2 = 0.3f - t2; //if (current_state == PlayModeStateChange.EnteredEditMode) // t2 = 0.1f - t2; if (bShowProgressBar) { EditorUtility.DisplayProgressBar(title8 + "-" + msg3, message, t2); progressBar_visible = true; } } else { bool modoDebug = false; modoDebug = true; if (modoDebug) { if (progressBar_visible) { progressBar_visible = false; marktime_close = time; } if (marktime_close > 0) { t3 = (time - marktime_close); if (t3 > totalProgTime) { marktime_close = 0; //t3 = 0; msg = "?"; msg3 = ""; EditorUtility.ClearProgressBar(); } else { //reverse float progress_t = (totalProgTime - t3) / totalProgTime; if (bShowProgressBar) { EditorUtility.DisplayProgressBar(title8 + "-" + msg3, message, progress_t); } } } } else { EditorUtility.ClearProgressBar(); } } if (action != null) { float t3 = 0; if (action.timeskip_marktime > 0) { t3 = time - action.timeskip_marktime; } if (action.showmessage != null) { string str3 = ""; if (t3 > 0) { str3 = " timeskip:" + t3.ToString("N3"); } debugStr1 = action.showmessage + action.frameskip + str3; // aguardando... executar acao //action.showmessage = null; } if (t3 > 0) { //float t3 = (float)EditorApplication.timeSinceStartup - action.timeskip_marktime; // 5 seconds if (t3 > 5) { Debug.Log("skip time:" + t3.ToString("N0")); action.timeskip_marktime = 0; } } else if (action.frameskip > 0) { //Debug.Log("skip frame:" + action.frameskip); action.frameskip--; if (action.frameskip == 0) { action.showmessage = null; } } else { if (action.nextAction == Action.action_RESTART_stop) { ShowToast("ScriptsReloaded - playing... STOP and RESTART..."); Debug.Log(" stop... doRestart"); EditorApplication.isPlaying = false; doRestart = 3; // done //next_action = null; next_action_List.Remove(action); } else if (action.nextAction == Action.action_RESTART_play) { Debug.Log(">>> >>> >>> restart ... Play!"); // Unity 2019 //EditorApplication.EnterPlaymode() if (!EditorApplication.isPlayingOrWillChangePlaymode) { EditorApplication.isPlaying = true; // done //next_action = null; next_action_List.Remove(action); } else { // falhou //next_action = null; next_action_List.Remove(action); } } else if (action.nextAction == Action.action_stop) { ShowToast("ScriptsReloaded - playing... STOP and RESTART..."); Debug.Log(" stop."); EditorApplication.isPlaying = false; // done //next_action = null; next_action_List.Remove(action); } else if (action.nextAction == Action.action_just_play) { ShowToast("ScriptsReloaded - not playing, just START"); //Debug.Log(">>> >>> >>> just start ... Play!"); // Unity 2019 //EditorApplication.EnterPlaymode() if (!EditorApplication.isPlayingOrWillChangePlaymode) { // not-compiling, not-playing, play, EditorApplication.isPlaying = true; Debug.Log(">>> >>> >>> play..."); // done //next_action = null; next_action_List.Remove(action); } else { // ignore, already playing //next_action = null; next_action_List.Remove(action); //Debug.LogError(">>> >>> >>> play falhou."); } } } } if (EditorApplication.isPlaying) { if (!_playing) { //Debug.LogWarning(">>> playing >>>"); //Debug.LogWarning(">>> >>> >>> playing"); _playing = true; } } else if (EditorApplication.isPlayingOrWillChangePlaymode) { } else { if (_playing) { //Debug.LogWarning("<<< NOT playing <<<"); Debug.LogWarning(">>> <<< <<< NOT playing"); _playing = false; } } if (current_state != _state) { _state = current_state; if (!autoRunDisable) { ShowToast("change:" + _state.ToString()); } } if (EditorApplication.isPlaying)//isPlaying) { //if (doSTOP) { //doSTOP = false; //if (doRestart == 2) //{ // // next action // CompileWindow.instance.DoIt(" restart...", Action.action_RESTART_play_stop); // doRestart = 3; // Debug.Log(" stop.ok doRestart :" + doRestart); //} } } else { if (current_state == PlayModeStateChange.ExitingPlayMode) { if (doRestart == 3) { //Debug.Log(" restart ... wait...");// doRestart :" + doRestart); } // STOP...? //wait //Debug.Log(" restart ... wait"); } else if (current_state == PlayModeStateChange.EnteredEditMode) { if (doRestart == 3) { Debug.Log(" restart ... doRestart :" + doRestart); Debug.Log(" restart ... PlayModeStateChange.EnteredEditMode"); doRestart = 0; // PLAY if (!EditorApplication.isPlayingOrWillChangePlaymode) { //doPlay = true; ShowToast("play..."); //doPlay_countdown = 3; // next action CompileWindow.instance.DoIt(" restart...", Action.action_RESTART_play); } else { //PlayModeStateChange.EnteredEditMode Debug.LogError(" restart error."); } } } } #region GUI bool newvalue = EditorGUILayout.Toggle("autoRunDisable", autoRunDisable); if (newvalue != autoRunDisable) { //autoRunDisable = EditorGUILayout.Toggle("auto-run", autoRunDisable); autoRunDisable = newvalue; if (autoRunDisable) { PlayerPrefs.SetInt("autoRunDisable", 1); } else { PlayerPrefs.SetInt("autoRunDisable", 0); } int newvalue2 = PlayerPrefs.GetInt("autoRunDisable"); Debug.Log(" new autoRunDisable=" + newvalue2); } EditorGUILayout.LabelField(debugStr1); Event e = Event.current; if (e.capsLock) { if (!capsLock) { capsLock = true; Debug.LogWarning(" capsLock = TRUE; "); IGNORE_ONCE = true; if (EditorApplication.isPlaying) //./.isPlaying) { //Debug.LogWarning(" capsLock, STOP; "); //STOP_ONCE = true; } else { } if (CompileWindow.instance != null) { CompileWindow.instance.autoRunDisable = true; } /* * if (EditorApplication.isPlaying) //./.isPlaying) * { * if (CompileWindow.instance != null) * CompileWindow.instance.DoIt(" play...", Action.action_stop); * } * else * { * if (CompileWindow.instance != null) * CompileWindow.instance.DoIt(" play...", Action.action_just_play); * } */ } //GUI.Label(new Rect(10, 10, 100, 20), "CapsLock on."); } else { if (capsLock) { Debug.LogWarning(" capsLock = false;"); capsLock = false; //var isCompiling = EditorApplication.isCompiling; if (!isCompiling) { if (EditorApplication.isPlaying) { //EditorGUILayout.LabelField("Playing"); if (EditorApplication.isPlaying) //./.isPlaying) { Debug.LogWarning(" capsLock, STOP; "); STOP_ONCE = true; } } else if (EditorApplication.isPlayingOrWillChangePlaymode) { //EditorGUILayout.LabelField("WillChangePlaymode"); } else { //EditorGUILayout.LabelField("Not playing"); //isCompiling //EditorApplication.LockReloadAssemblies(); //EditorApplication.LockReloadAssemblies(); Debug.LogWarning(" capsLock, PLAY; "); if (CompileWindow.instance != null) { CompileWindow.instance.DoIt(" play...", Action.action_just_play); } } } } } if (e.capsLock) { GUI.Label(new Rect(10, 10, 100, 20), "CapsLock on."); } else { GUI.Label(new Rect(10, 10, 100, 20), "CapsLock off."); } if (action != null) { EditorGUILayout.LabelField("next action:" + action.nextAction); } else { EditorGUILayout.LabelField("next action: ---"); } if (EditorApplication.isPlaying) { EditorGUILayout.LabelField("Playing"); } else if (EditorApplication.isPlayingOrWillChangePlaymode) { EditorGUILayout.LabelField("WillChangePlaymode"); } else { EditorGUILayout.LabelField("Not playing"); } EditorGUILayout.LabelField("time :" + t.ToString("N3")); // isCompiling ? "Yes" : "No"); //EditorGUILayout.LabelField("marktime:" + marktime.ToString("N3"));// isCompiling ? "Yes" : "No"); this.Repaint(); #endregion }