protected override void OldOnGUI() { const float space = 8; 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(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)); 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 (Unity.MPE.ProcessService.level == Unity.MPE.ProcessLevel.UMP_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(); } } EditorGUI.ShowRepaints(); Highlighter.ControlHighlightGUI(this); }
void DoToolSettings(Rect rect) { rect = EditorToolGUI.GetThinArea(rect); EditorToolGUI.DoBuiltinToolSettings(rect, Styles.buttonLeft, Styles.buttonRight); }
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(32, ref pos); if (GUI.Button(EditorToolGUI.GetThinArea(pos), s_CloudIcon)) { 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) { 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); }