public void OnEnable() { prevSizeGroupType = (int)currentSizeGroupType; titleContent = GetLocalizedTitleContent(); UpdateZoomAreaAndParent(); showToolbar = ModeService.HasCapability(ModeCapability.GameViewToolbar, true); ModeService.modeChanged += OnEditorModeChanged; EditorApplication.playModeStateChanged += OnPlayModeStateChanged; }
protected override void OnEnable() { base.OnEnable(); s_AppStatusBar = this; m_autoLightBakingOn = GetBakeMode(); m_ManagedDebuggerToggle = new ManagedDebuggerToggle(); m_CacheServerToggle = new CacheServerToggle(); m_EventInterests.wantsLessLayoutEvents = true; m_DrawExtraFeatures = ModeService.HasCapability(ModeCapability.StatusBarExtraFeatures, true); Progress.added += RefreshProgressBar; Progress.removed += RefreshProgressBar; Progress.updated += RefreshProgressBar; }
internal static void BuildWindowMenuListing() { if (!ModeService.HasCapability(ModeCapability.LayoutWindowMenu, true)) { return; } const string k_RootMenuItemName = "Window/Panels"; Menu.RemoveMenuItem(k_RootMenuItemName); var editorWindows = Resources.FindObjectsOfTypeAll <EditorWindow>(); int menuIdx = -10; Menu.AddMenuItem($"{k_RootMenuItemName}/Close all floating panels...", "", false, menuIdx++, () => { var windows = Resources.FindObjectsOfTypeAll <ContainerWindow>(); foreach (var win in windows.Where(w => !!w && w.showMode != ShowMode.MainWindow)) { win.Close(); } }, null); Menu.AddSeparator($"{k_RootMenuItemName}/", menuIdx++); int menuIndex = 1; foreach (var win in editorWindows.Where(e => !!e).OrderBy(e => e.titleContent.text)) { var title = win.titleContent.text; if (!String.IsNullOrEmpty(win.titleContent.tooltip) && win.titleContent.tooltip != title) { title = win.titleContent.tooltip; } title = title.Replace("/", "\\"); Menu.AddMenuItem($"{k_RootMenuItemName}/{menuIndex++} {title}", "", false, menuIdx++, () => win.Focus(), null); } }
private void OnEditorModeChanged(ModeService.ModeChangedArgs args) { showToolbar = ModeService.HasCapability(ModeCapability.GameViewToolbar, true); Repaint(); }
public override void OnGUI() { const float space = 8; const float standardButtonWidth = 32; const float dropdownWidth = 80; const float playPauseStopWidth = 140; const float previewPackagesinUseWidth = 173; const float previewPackagesinUseIconWidth = 45; InitializeToolIcons(); bool isOrWillEnterPlaymode = EditorApplication.isPlayingOrWillChangePlaymode; GUI.color = isOrWillEnterPlaymode ? HostView.kPlayModeDarken : Color.white; if (Event.current.type == EventType.Repaint) { Styles.appToolbar.Draw(new Rect(0, 0, position.width, position.height), false, false, false, false); } // Position left aligned controls controls - start from left to right. Rect pos = new Rect(0, 0, 0, 0); ReserveWidthRight(space, ref pos); ReserveWidthRight(standardButtonWidth * s_ShownToolIcons.Length, ref pos); DoToolButtons(EditorToolGUI.GetThickArea(pos)); ReserveWidthRight(space, ref pos); int playModeControlsStart = Mathf.RoundToInt((position.width - playPauseStopWidth) / 2); pos.x += pos.width; const float pivotButtonsWidth = 128; pos.width = pivotButtonsWidth; DoToolSettings(EditorToolGUI.GetThickArea(pos)); pos.width = pivotButtonsWidth; ReserveWidthRight(standardButtonWidth, ref pos); DoSnapButtons(EditorToolGUI.GetThickArea(pos)); // Position centered controls. pos = new Rect(playModeControlsStart, 0, 240, 0); if (ModeService.HasCapability(ModeCapability.Playbar, true)) { GUILayout.BeginArea(EditorToolGUI.GetThickArea(pos)); GUILayout.BeginHorizontal(); { if (!ModeService.Execute("gui_playbar", isOrWillEnterPlaymode)) { DoPlayButtons(isOrWillEnterPlaymode); } } GUILayout.EndHorizontal(); GUILayout.EndArea(); } // Position right aligned controls controls - start from right to left. pos = new Rect(position.width, 0, 0, 0); // Right spacing side ReserveWidthLeft(space, ref pos); ReserveWidthLeft(dropdownWidth, ref pos); if (ModeService.HasCapability(ModeCapability.LayoutWindowMenu, true)) { DoLayoutDropDown(EditorToolGUI.GetThinArea(pos)); } if (ModeService.HasCapability(ModeCapability.Layers, true)) { ReserveWidthLeft(space, ref pos); ReserveWidthLeft(dropdownWidth, ref pos); DoLayersDropDown(EditorToolGUI.GetThinArea(pos)); } if (UnityEditor.MPE.ProcessService.level == UnityEditor.MPE.ProcessLevel.Master) { ReserveWidthLeft(space, ref pos); ReserveWidthLeft(dropdownWidth, ref pos); if (EditorGUI.DropdownButton(EditorToolGUI.GetThinArea(pos), s_AccountContent, FocusType.Passive, Styles.dropdown)) { ShowUserMenu(EditorToolGUI.GetThinArea(pos)); } ReserveWidthLeft(space, ref pos); ReserveWidthLeft(standardButtonWidth, ref pos); if (GUI.Button(EditorToolGUI.GetThinArea(pos), s_CloudIcon, Styles.command)) { ServicesEditorWindow.ShowServicesWindow(); } } foreach (SubToolbar subToolbar in s_SubToolbars) { ReserveWidthLeft(space, ref pos); ReserveWidthLeft(subToolbar.Width, ref pos); subToolbar.OnGUI(EditorToolGUI.GetThinArea(pos)); } if (Unsupported.IsDeveloperBuild() && ModeService.hasSwitchableModes) { EditorGUI.BeginChangeCheck(); ReserveWidthLeft(space, ref pos); ReserveWidthLeft(dropdownWidth, ref pos); var selectedModeIndex = EditorGUI.Popup(EditorToolGUI.GetThinArea(pos), ModeService.currentIndex, ModeService.modeNames, Styles.dropdown); if (EditorGUI.EndChangeCheck()) { EditorApplication.delayCall += () => ModeService.ChangeModeByIndex(selectedModeIndex); GUIUtility.ExitGUI(); } } if (m_IsPreviewPackagesInUse && !m_PackageManagerPrefs.dismissPreviewPackagesInUse) { ReserveWidthLeft(space, ref pos); var useIcon = Toolbar.get.mainToolbar.position.width < k_MinWidthChangePreviewPackageInUseToIcon; ReserveWidthLeft(useIcon ? previewPackagesinUseIconWidth : previewPackagesinUseWidth, ref pos); var dropDownCustomColor = new GUIStyle(Styles.previewPackageInUseDropdown); if (EditorGUI.DropdownButton(EditorToolGUI.GetThinArea(pos), useIcon ? s_PreviewPackageIcon : s_PreviewPackageContent, FocusType.Passive, dropDownCustomColor)) { ShowPreviewPackageInUseMenu(EditorToolGUI.GetThinArea(pos)); } } EditorGUI.ShowRepaints(); }
protected override void OldOnGUI() { const float space = 10; const float largeSpace = 20; const float standardButtonWidth = 32; const float dropdownWidth = 80; const float playPauseStopWidth = 140; InitializeToolIcons(); bool isOrWillEnterPlaymode = EditorApplication.isPlayingOrWillChangePlaymode; GUI.color = isOrWillEnterPlaymode ? HostView.kPlayModeDarken : Color.white; if (Event.current.type == EventType.Repaint) { Styles.appToolbar.Draw(new Rect(0, 0, position.width, position.height), false, false, false, false); } // Position left aligned controls controls - start from left to right. Rect pos = new Rect(0, 0, 0, 0); ReserveWidthRight(space, ref pos); ReserveWidthRight(standardButtonWidth * s_ShownToolIcons.Length, ref pos); DoToolButtons(EditorToolGUI.GetThickArea(pos)); ReserveWidthRight(largeSpace, ref pos); int playModeControlsStart = Mathf.RoundToInt((position.width - playPauseStopWidth) / 2); pos.x += pos.width; pos.width = (playModeControlsStart - pos.x) - largeSpace; DoToolSettings(EditorToolGUI.GetThickArea(pos)); // Position centered controls. pos = new Rect(playModeControlsStart, 0, 240, 0); if (ModeService.HasCapability(ModeCapability.Playbar, true)) { GUILayout.BeginArea(EditorToolGUI.GetThickArea(pos)); GUILayout.BeginHorizontal(); { if (!ModeService.Execute("gui_playbar", isOrWillEnterPlaymode)) { DoPlayButtons(isOrWillEnterPlaymode); } } GUILayout.EndHorizontal(); GUILayout.EndArea(); } // Position right aligned controls controls - start from right to left. pos = new Rect(position.width, 0, 0, 0); // Right spacing side ReserveWidthLeft(space, ref pos); ReserveWidthLeft(dropdownWidth, ref pos); DoLayoutDropDown(EditorToolGUI.GetThinArea(pos)); if (ModeService.HasCapability(ModeCapability.Layers, true)) { ReserveWidthLeft(space, ref pos); ReserveWidthLeft(dropdownWidth, ref pos); DoLayersDropDown(EditorToolGUI.GetThinArea(pos)); } ReserveWidthLeft(space, ref pos); ReserveWidthLeft(dropdownWidth, ref pos); if (EditorGUI.DropdownButton(EditorToolGUI.GetThinArea(pos), s_AccountContent, FocusType.Passive, Styles.dropdown)) { ShowUserMenu(EditorToolGUI.GetThinArea(pos)); } ReserveWidthLeft(space, ref pos); ReserveWidthLeft(standardButtonWidth, ref pos); if (GUI.Button(EditorToolGUI.GetThinArea(pos), s_CloudIcon, Styles.command)) { UnityConnectServiceCollection.instance.ShowService(HubAccess.kServiceName, true, "cloud_icon"); // Should show hub when it's done } foreach (SubToolbar subToolbar in s_SubToolbars) { ReserveWidthLeft(space, ref pos); ReserveWidthLeft(subToolbar.Width, ref pos); subToolbar.OnGUI(EditorToolGUI.GetThinArea(pos)); } if (ModeService.modeCount > 1 && Unsupported.IsDeveloperBuild()) { EditorGUI.BeginChangeCheck(); ReserveWidthLeft(space, ref pos); ReserveWidthLeft(dropdownWidth, ref pos); var selectedModeIndex = EditorGUI.Popup(EditorToolGUI.GetThinArea(pos), ModeService.currentIndex, ModeService.modeNames, Styles.dropdown); if (EditorGUI.EndChangeCheck()) { EditorApplication.delayCall += () => ModeService.ChangeModeByIndex(selectedModeIndex); GUIUtility.ExitGUI(); } } EditorGUI.ShowRepaints(); Highlighter.ControlHighlightGUI(this); }