private static void HandleEditorStartedCompiling() { CompileTimeTracker._data.StartTime = TrackingUtil.GetMilliseconds(); UnityConsoleCountsByType countsByType = UnityEditorConsoleUtil.GetCountsByType(); CompileTimeTracker.StoredErrorCount = countsByType.errorCount; }
private static void HandleEditorFinishedCompiling() { int elapsedTime = TrackingUtil.GetMilliseconds() - CompileTimeTracker._data.StartTime; UnityConsoleCountsByType countsByType = UnityEditorConsoleUtil.GetCountsByType(); bool hasErrors = (countsByType.errorCount - CompileTimeTracker.StoredErrorCount) > 0; CompileTimeKeyframe keyframe = new CompileTimeKeyframe(elapsedTime, hasErrors); CompileTimeTracker._data.AddCompileTimeKeyframe(keyframe); CompileTimeTracker.KeyframeAdded.Invoke(keyframe); }
private static void LogCompileTimeKeyframe(CompileTimeKeyframe keyframe) { bool dontLogToConsole = !CompileTimeTrackerWindow.LogToConsole; if (dontLogToConsole) { return; } string compilationFinishedLog = "Compilation Finished: " + TrackingUtil.FormatMSTime(keyframe.elapsedCompileTimeInMS); if (keyframe.hadErrors) { compilationFinishedLog += " (error)"; } UnityEngine.Debug.Log(compilationFinishedLog); }
void OnGUI() { Rect screenRect = this.position; int totalCompileTimeInMS = 0; // show filters EditorGUILayout.BeginHorizontal(GUILayout.Height(20.0f)); EditorGUILayout.Space(); float toggleRectWidth = screenRect.width / 4.0f; Rect toggleRect = new Rect(0.0f, 0.0f, width: toggleRectWidth, height: 20.0f); // Psuedo enum logic here if (CompileTimeTrackerWindow.OnlyToday && CompileTimeTrackerWindow.OnlyYesterday) { CompileTimeTrackerWindow.OnlyYesterday = false; } if (!CompileTimeTrackerWindow.OnlyToday && !CompileTimeTrackerWindow.OnlyYesterday) { CompileTimeTrackerWindow.OnlyToday = true; } bool newOnlyToday = GUI.Toggle(toggleRect, CompileTimeTrackerWindow.OnlyToday, "Today", (GUIStyle)"Button"); if (newOnlyToday != CompileTimeTrackerWindow.OnlyToday) { CompileTimeTrackerWindow.OnlyToday = newOnlyToday; CompileTimeTrackerWindow.OnlyYesterday = !newOnlyToday; } toggleRect.position = toggleRect.position.AddX(toggleRectWidth); bool newOnlyYesterday = GUI.Toggle(toggleRect, CompileTimeTrackerWindow.OnlyYesterday, "Yesterday", (GUIStyle)"Button"); if (newOnlyYesterday != CompileTimeTrackerWindow.OnlyYesterday) { CompileTimeTrackerWindow.OnlyYesterday = newOnlyYesterday; CompileTimeTrackerWindow.OnlyToday = !newOnlyYesterday; } // End psuedo enum logic toggleRect.position = toggleRect.position.AddX(2.0f * toggleRectWidth); CompileTimeTrackerWindow.ShowErrors = GUI.Toggle(toggleRect, CompileTimeTrackerWindow.ShowErrors, "Errors", (GUIStyle)"Button"); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(GUILayout.Height(20.0f)); CompileTimeTrackerWindow.LogToConsole = EditorGUILayout.Toggle("Log Compile Time", CompileTimeTrackerWindow.LogToConsole); EditorGUILayout.EndHorizontal(); this._scrollPosition = EditorGUILayout.BeginScrollView(this._scrollPosition, GUILayout.Height(screenRect.height - 64.0f)); foreach (CompileTimeKeyframe keyframe in this.GetFilteredKeyframes()) { string compileText = string.Format("({0:hh:mm tt}): ", keyframe.Date); compileText += TrackingUtil.FormatMSTime(keyframe.elapsedCompileTimeInMS); if (keyframe.hadErrors) { compileText += " (error)"; } GUILayout.Label(compileText); totalCompileTimeInMS += keyframe.elapsedCompileTimeInMS; } EditorGUILayout.EndScrollView(); string statusBarText = "Total compile time: " + TrackingUtil.FormatMSTime(totalCompileTimeInMS); if (EditorApplication.isCompiling) { statusBarText = "Compiling.. || " + statusBarText; } EditorGUILayout.BeginHorizontal(GUILayout.Height(24.0f)); GUILayout.Label(statusBarText); if (GUILayout.Button("Export CSV", GUILayout.ExpandWidth(false))) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("All"), false, ExportAllCSV); menu.AddItem(new GUIContent("Filtered"), false, ExportFilteredCSV); menu.ShowAsContext(); } EditorGUILayout.EndHorizontal(); }