private void DrawRefreshStatus() { bool compiling = EditorApplication.isCompiling; bool assembliesLocked = !EditorApplication.CanReloadAssemblies(); if (compiling || showProgress) { if (assembliesLocked) { GUILayout.Button(Styles.assemblyLock, Styles.statusIcon); } else { int frame = (int)Mathf.Repeat(Time.realtimeSinceStartup * 10, 11.99f); GUILayout.Button(Styles.statusWheel[frame], Styles.statusIcon); } } else { if (GUILayout.Button(Styles.progressIcon, Styles.statusIcon)) { Progress.ShowDetails(); } var buttonRect = GUILayoutUtility.GetLastRect(); EditorGUIUtility.AddCursorRect(buttonRect, MouseCursor.Link); } GUILayout.Space(Styles.spacing); if (Unsupported.IsBleedingEdgeBuild()) { var backup = GUI.color; GUI.color = Color.yellow; GUILayout.Label("THIS IS AN UNTESTED BLEEDINGEDGE UNITY BUILD"); GUI.color = backup; } else if (Unsupported.IsDeveloperMode()) { GUILayout.Label(m_MiniMemoryOverview, Styles.statusLabel); EditorGUIUtility.CleanCache(m_MiniMemoryOverview); } }
private void DrawSpecialModeLabel() { if (Unsupported.IsBleedingEdgeBuild()) { GUILayout.Space(k_SpaceBeforeProgress); m_SpecialModeLabel = "THIS IS AN UNTESTED BLEEDINGEDGE UNITY BUILD"; var backup = GUI.color; GUI.color = Color.yellow; GUILayout.Label(m_SpecialModeLabel); GUI.color = backup; } else if (Unsupported.IsDeveloperMode()) { GUILayout.Space(k_SpaceBeforeProgress); m_SpecialModeLabel = m_MiniMemoryOverview; GUILayout.Label(m_SpecialModeLabel, Styles.statusLabel); EditorGUIUtility.CleanCache(m_MiniMemoryOverview); } else { m_SpecialModeLabel = ""; } }
/// <summary> /// Default implementation of the build player method. /// </summary> /// <param name="options"></param> public static void BuildPlayer(BuildPlayerOptions options) { if (!UnityConnect.instance.canBuildWithUPID) { if (!EditorUtility.DisplayDialog("Missing Project ID", "Because you are not a member of this project this build will not access Unity services.\nDo you want to continue?", "Yes", "No")) { throw new BuildMethodException(); } } if (!BuildPipeline.IsBuildTargetSupported(options.targetGroup, options.target)) { throw new BuildMethodException("Build target is not supported."); } string module = ModuleManager.GetTargetStringFrom(EditorUserBuildSettings.selectedBuildTargetGroup, options.target); IBuildWindowExtension buildWindowExtension = ModuleManager.GetBuildWindowExtension(module); if (buildWindowExtension != null && (options.options & BuildOptions.AutoRunPlayer) != 0 && !buildWindowExtension.EnabledBuildAndRunButton()) { throw new BuildMethodException(); } if (Unsupported.IsBleedingEdgeBuild()) { var sb = new System.Text.StringBuilder(); sb.AppendLine("This version of Unity is a BleedingEdge build that has not seen any manual testing."); sb.AppendLine("You should consider this build unstable."); sb.AppendLine("We strongly recommend that you use a normal version of Unity instead."); if (EditorUtility.DisplayDialog("BleedingEdge Build", sb.ToString(), "Cancel", "OK")) { throw new BuildMethodException(); } } // See if we need to switch platforms and delay the build. We do this whenever // we're trying to build for a target different from the active one so as to ensure // that the compiled script code we have loaded is built for the same platform we // are building for. As we can't reload while our editor stuff is still executing, // we need to defer to after the next script reload then. bool delayToAfterScriptReload = false; if (EditorUserBuildSettings.activeBuildTarget != options.target || EditorUserBuildSettings.activeBuildTargetGroup != options.targetGroup) { if (!EditorUserBuildSettings.SwitchActiveBuildTargetAsync(options.targetGroup, options.target)) { // Switching the build target failed. No point in trying to continue // with a build. var errStr = string.Format("Could not switch to build target '{0}', '{1}'.", BuildPipeline.GetBuildTargetGroupDisplayName(options.targetGroup), BuildPlatforms.instance.GetBuildTargetDisplayName(options.targetGroup, options.target)); throw new BuildMethodException(errStr); } if (EditorApplication.isCompiling) { delayToAfterScriptReload = true; } } // Trigger build. // Note: report will be null, if delayToAfterScriptReload = true var report = BuildPipeline.BuildPlayerInternalNoCheck(options.scenes, options.locationPathName, null, options.targetGroup, options.target, options.options, delayToAfterScriptReload); if (report != null) { var resultStr = String.Format("Build completed with a result of '{0}'", report.summary.result.ToString("g")); switch (report.summary.result) { case Build.Reporting.BuildResult.Unknown: Debug.LogWarning(resultStr); break; case Build.Reporting.BuildResult.Failed: DeleteBuildFolderIfEmpty(report.summary.outputPath); Debug.LogError(resultStr); throw new BuildMethodException(report.SummarizeErrors()); default: Debug.Log(resultStr); break; } buildCompletionHandler?.Invoke(report); } }
private void OnGUI() { ConsoleWindow.LoadIcons(); if (background == null) { background = "AppToolbar"; } if (EditorApplication.isPlayingOrWillChangePlaymode) { GUI.color = (Color)HostView.kPlayModeDarken; } if (Event.current.type == EventType.Repaint) { background.Draw(new Rect(0f, 0f, base.position.width, base.position.height), false, false, false, false); } bool isCompiling = EditorApplication.isCompiling; GUILayout.Space(2f); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Space(2f); string statusText = LogEntries.GetStatusText(); if (statusText != null) { int statusMask = LogEntries.GetStatusMask(); GUIStyle statusStyleForErrorMode = ConsoleWindow.GetStatusStyleForErrorMode(statusMask); GUILayout.Label(ConsoleWindow.GetIconForErrorMode(statusMask, false), statusStyleForErrorMode, new GUILayoutOption[0]); GUILayout.Space(2f); GUILayout.BeginVertical(new GUILayoutOption[0]); GUILayout.Space(2f); if (isCompiling) { GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MaxWidth(GUIView.current.position.width - 52f) }; GUILayout.Label(statusText, statusStyleForErrorMode, options); } else { GUILayout.Label(statusText, statusStyleForErrorMode, new GUILayoutOption[0]); } GUILayout.FlexibleSpace(); GUILayout.EndVertical(); if (Event.current.type == EventType.MouseDown) { Event.current.Use(); LogEntries.ClickStatusBar(Event.current.clickCount); GUIUtility.ExitGUI(); } } GUILayout.EndHorizontal(); if (Event.current.type == EventType.Repaint) { float x = base.position.width - 24f; if (AsyncProgressBar.isShowing) { x -= 188f; EditorGUI.ProgressBar(new Rect(x, 0f, 185f, 19f), AsyncProgressBar.progress, AsyncProgressBar.progressInfo); } if (isCompiling) { int index = (int)Mathf.Repeat(Time.realtimeSinceStartup * 10f, 11.99f); GUI.Label(new Rect(base.position.width - 24f, 0f, (float)s_StatusWheel[index].image.width, (float)s_StatusWheel[index].image.height), s_StatusWheel[index], GUIStyle.none); } if (Unsupported.IsBleedingEdgeBuild()) { Color color = GUI.color; GUI.color = Color.yellow; GUI.Label(new Rect(x - 310f, 0f, 310f, 19f), "THIS IS AN UNTESTED BLEEDINGEDGE UNITY BUILD"); GUI.color = color; } else if (Unsupported.IsDeveloperBuild()) { GUI.Label(new Rect(x - 200f, 0f, 200f, 19f), this.m_LastMiniMemoryOverview, EditorStyles.progressBarText); EditorGUIUtility.CleanCache(this.m_LastMiniMemoryOverview); } } base.DoWindowDecorationEnd(); EditorGUI.ShowRepaints(); }
protected override void OldOnGUI() { const int spacing = 4; const int statusWheelWidth = 24; const int progressBarWidth = 185; float lightingBakeModeBarWidth = EditorStyles.progressBarText.CalcSize(EditorGUIUtility.TempContent(m_BakeModeString)).x; const int barHeight = 19; ConsoleWindow.LoadIcons(); if (background == null) { background = "AppToolbar"; } GUI.color = EditorApplication.isPlayingOrWillChangePlaymode ? HostView.kPlayModeDarken : Color.white; if (Event.current.type == EventType.Repaint) { background.Draw(new Rect(0, 0, position.width, position.height), false, false, false, false); } bool compiling = EditorApplication.isCompiling; bool assembliesLocked = !EditorApplication.CanReloadAssemblies(); GUILayout.BeginHorizontal(); GUILayout.Space(2); float statusBarItemsWidth = statusWheelWidth + (AsyncProgressBar.isShowing ? (progressBarWidth + spacing) : 0) + (showBakeMode ? (lightingBakeModeBarWidth + spacing) : 0); if (Event.current.type == EventType.MouseDown) { Rect rect = new Rect(position.width - statusBarItemsWidth - m_ManagedDebuggerToggle.GetWidth(), 0, lightingBakeModeBarWidth, barHeight); if (rect.Contains(Event.current.mousePosition)) { Event.current.Use(); LightingWindow.CreateLightingWindow(); } } string statusText = LogEntries.GetStatusText(); if (statusText != null) { // Render int mask = LogEntries.GetStatusMask(); GUIStyle errorStyle = ConsoleWindow.GetStatusStyleForErrorMode(mask); Texture2D icon = ConsoleWindow.GetIconForErrorMode(mask, false); GUILayout.Label(icon, errorStyle); GUILayout.Space(2); GUILayout.BeginVertical(); GUILayout.Space(1); float statusTextWidth = GUIView.current.position.width - statusBarItemsWidth - m_ManagedDebuggerToggle.GetWidth() - (icon != null ? icon.width : 0); GUILayout.Label(statusText, errorStyle, GUILayout.MaxWidth(statusTextWidth)); GUILayout.FlexibleSpace(); GUILayout.EndVertical(); // Handle status bar click if (Event.current.type == EventType.MouseDown) { Rect rect = new Rect(0, 0, statusTextWidth, barHeight); if (rect.Contains(Event.current.mousePosition)) { Event.current.Use(); LogEntries.ClickStatusBar(Event.current.clickCount); GUIUtility.ExitGUI(); } } } float managedDebuggerTogglePosX = position.width - statusWheelWidth - m_ManagedDebuggerToggle.GetWidth(); m_ManagedDebuggerToggle.OnGUI(managedDebuggerTogglePosX, 0); GUILayout.EndHorizontal(); if (Event.current.type == EventType.Repaint) { float progressBarHorizontalPosition = position.width - statusWheelWidth - m_ManagedDebuggerToggle.GetWidth(); if (AsyncProgressBar.isShowing) { progressBarHorizontalPosition -= progressBarWidth + spacing; EditorGUI.ProgressBar(new Rect(progressBarHorizontalPosition, 0, progressBarWidth, barHeight), AsyncProgressBar.progress, AsyncProgressBar.progressInfo); } if (showBakeMode) { GUI.Label(new Rect(progressBarHorizontalPosition - lightingBakeModeBarWidth - spacing, 0, lightingBakeModeBarWidth, barHeight), m_BakeModeString, EditorStyles.progressBarText); progressBarHorizontalPosition -= lightingBakeModeBarWidth + spacing; } if (compiling) { if (assembliesLocked) { GUI.Label(new Rect(position.width - statusWheelWidth, 0, s_AssemblyLock.image.width, s_AssemblyLock.image.height), s_AssemblyLock, GUIStyle.none); } else { int frame = (int)Mathf.Repeat(Time.realtimeSinceStartup * 10, 11.99f); GUI.Label(new Rect(position.width - statusWheelWidth, 0, s_StatusWheel[frame].image.width, s_StatusWheel[frame].image.height), s_StatusWheel[frame], GUIStyle.none); } } if (Unsupported.IsBleedingEdgeBuild()) { var backup = GUI.color; GUI.color = Color.yellow; GUI.Label(new Rect(progressBarHorizontalPosition - 310 - spacing, 0, 310, barHeight), "THIS IS AN UNTESTED BLEEDINGEDGE UNITY BUILD"); GUI.color = backup; } else if (Unsupported.IsDeveloperMode()) { GUI.Label(new Rect(progressBarHorizontalPosition - 300 - spacing, 0, 300, barHeight), m_MiniMemoryOverview, EditorStyles.progressBarText); EditorGUIUtility.CleanCache(m_MiniMemoryOverview); } } DoWindowDecorationEnd(); EditorGUI.ShowRepaints(); }
protected override void OldOnGUI() { ConsoleWindow.LoadIcons(); if (background == null) { background = "AppToolbar"; } if (EditorApplication.isPlayingOrWillChangePlaymode) { GUI.color = HostView.kPlayModeDarken; } if (Event.current.type == EventType.Repaint) { background.Draw(new Rect(0, 0, position.width, position.height), false, false, false, false); } bool compiling = EditorApplication.isCompiling; GUILayout.Space(2); GUILayout.BeginHorizontal(); GUILayout.Space(2); string statusText = LogEntries.GetStatusText(); if (statusText != null) { // Render int mask = LogEntries.GetStatusMask(); GUIStyle errorStyle = ConsoleWindow.GetStatusStyleForErrorMode(mask); GUILayout.Label(ConsoleWindow.GetIconForErrorMode(mask, false), errorStyle); GUILayout.Space(2); GUILayout.BeginVertical(); GUILayout.Space(2); if (compiling) //leave space for indicator { GUILayout.Label(statusText, errorStyle, GUILayout.MaxWidth(GUIView.current.position.width - 52)); } else { GUILayout.Label(statusText, errorStyle); } GUILayout.FlexibleSpace(); GUILayout.EndVertical(); // Handle status bar click if (Event.current.type == EventType.MouseDown) { Event.current.Use(); LogEntries.ClickStatusBar(Event.current.clickCount); GUIUtility.ExitGUI(); } } GUILayout.EndHorizontal(); if (Event.current.type == EventType.Repaint) { const float statusWheelWidth = 24; const float progressBarStatusWheelSpacing = 3; float progressBarHorizontalPosition = position.width - statusWheelWidth; if (AsyncProgressBar.isShowing) { const int progressBarWidth = 185; progressBarHorizontalPosition -= progressBarWidth + progressBarStatusWheelSpacing; EditorGUI.ProgressBar(new Rect(progressBarHorizontalPosition, 0, progressBarWidth, 19), AsyncProgressBar.progress, AsyncProgressBar.progressInfo); } if (compiling) { int frame = (int)Mathf.Repeat(Time.realtimeSinceStartup * 10, 11.99f); GUI.Label(new Rect(position.width - statusWheelWidth, 0, s_StatusWheel[frame].image.width, s_StatusWheel[frame].image.height), s_StatusWheel[frame], GUIStyle.none); } if (Unsupported.IsBleedingEdgeBuild()) { var backup = GUI.color; GUI.color = Color.yellow; GUI.Label(new Rect(progressBarHorizontalPosition - 310, 0, 310, 19), "THIS IS AN UNTESTED BLEEDINGEDGE UNITY BUILD"); GUI.color = backup; } else if (Unsupported.IsDeveloperMode()) { GUI.Label(new Rect(progressBarHorizontalPosition - 200, 0, 200, 19), m_LastMiniMemoryOverview, EditorStyles.progressBarText); EditorGUIUtility.CleanCache(m_LastMiniMemoryOverview); } } DoWindowDecorationEnd(); EditorGUI.ShowRepaints(); }