void OnGUI() { GUILayout.Space(5); Event evt = Event.current; bool hitEnter = evt.type == EventType.KeyDown && (evt.keyCode == KeyCode.Return || evt.keyCode == KeyCode.KeypadEnter); GUI.SetNextControlName("m_PreferencesName"); m_LayoutName = EditorGUILayout.TextField(m_LayoutName); if (!didFocus) { didFocus = true; EditorGUI.FocusTextInControl("m_PreferencesName"); } GUI.enabled = m_LayoutName.Length != 0; if (GUILayout.Button("Save") || hitEnter) { Close(); string path = Path.Combine(WindowLayout.layoutsPreferencesPath, m_LayoutName + ".wlt"); Toolbar.lastLoadedLayoutName = m_LayoutName; WindowLayout.SaveWindowLayout(path); InternalEditorUtility.ReloadWindowLayoutMenu(); GUIUtility.ExitGUI(); } }
private void OnGUI() { GUILayout.Space(5f); Event current = Event.current; bool flag = current.type == EventType.KeyDown && (current.keyCode == KeyCode.Return || current.keyCode == KeyCode.KeypadEnter); GUI.SetNextControlName("m_PreferencesName"); this.m_LayoutName = EditorGUILayout.TextField(this.m_LayoutName); if (!this.didFocus) { this.didFocus = true; EditorGUI.FocusTextInControl("m_PreferencesName"); } GUI.enabled = this.m_LayoutName.Length != 0; if (!GUILayout.Button("Save") && !flag) { return; } this.Close(); string path = Path.Combine(WindowLayout.layoutsPreferencesPath, this.m_LayoutName + ".wlt"); Toolbar.lastLoadedLayoutName = this.m_LayoutName; WindowLayout.SaveWindowLayout(path); InternalEditorUtility.ReloadWindowLayoutMenu(); GUIUtility.ExitGUI(); }
void OnGUI() { GUILayout.Space(5); Event evt = Event.current; bool hitEnter = evt.type == EventType.KeyDown && (evt.keyCode == KeyCode.Return || evt.keyCode == KeyCode.KeypadEnter); GUI.SetNextControlName("m_PreferencesName"); EditorGUI.BeginChangeCheck(); s_LayoutName = EditorGUILayout.TextField(s_LayoutName); if (EditorGUI.EndChangeCheck()) { UpdateCurrentInvalidChars(); } if (!m_DidFocus) { m_DidFocus = true; EditorGUI.FocusTextInControl("m_PreferencesName"); } if (s_CurrentInvalidChars.Length != 0) { EditorGUILayout.HelpBox(string.Format(s_InvalidCharsFormatString, s_CurrentInvalidChars), MessageType.Warning); minSize = new Vector2(k_Width, k_Height + k_HelpBoxHeight); } else { minSize = new Vector2(k_Width, k_Height); } bool canSaveLayout = s_LayoutName.Length > 0 && s_CurrentInvalidChars.Length == 0; EditorGUI.BeginDisabled(!canSaveLayout); if (GUILayout.Button("Save") || hitEnter && canSaveLayout) { Close(); if (!Directory.Exists(WindowLayout.layoutsModePreferencesPath)) { Directory.CreateDirectory(WindowLayout.layoutsModePreferencesPath); } string path = Path.Combine(WindowLayout.layoutsModePreferencesPath, s_LayoutName + ".wlt"); Toolbar.lastLoadedLayoutName = s_LayoutName; WindowLayout.SaveWindowLayout(path); WindowLayout.ReloadWindowLayoutMenu(); EditorUtility.Internal_UpdateAllMenus(); ShortcutIntegration.instance.RebuildShortcuts(); GUIUtility.ExitGUI(); } else { m_DidFocus = false; } EditorGUI.EndDisabled(); }
static void InitializeProfilerSlaveProcessDomain() { if (s_SlaveProfilerWindow == null && EditorWindow.HasOpenInstances <ProfilerWindow>()) { s_SlaveProfilerWindow = EditorWindow.GetWindow <ProfilerWindow>(); SetupProfilerWindow(s_SlaveProfilerWindow); } EventService.On(nameof(EventType.UmpProfilerRecordToggle), HandleToggleRecording); EventService.On(nameof(EventType.UmpProfilerRequestRecordState), HandleRequestRecordState); EventService.On(nameof(EventType.UmpProfilerPing), HandlePingEvent); EventService.On(nameof(EventType.UmpProfilerExit), HandleExitEvent); EditorApplication.updateMainWindowTitle += SetProfilerWindowTitle; EditorApplication.quitting += () => WindowLayout.SaveWindowLayout(userPrefProfilerLayoutPath); }
private static void OnModeChangeLayouts(ModeChangedArgs args) { // Prevent double loading the default/last layout already done by the WindowLayout system. if (args.prevIndex == -1) { return; } if (!HasCapability(ModeCapability.LayoutSwitching, true)) { return; } // Save previous mode layout var prevLayoutPath = Path.Combine(Application.temporaryCachePath, $"{k_ModeLayoutKeyName}-{GetModeId(args.prevIndex)}.wlt"); WindowLayout.SaveWindowLayout(prevLayoutPath); // Load exiting layout if available var modeLayoutPath = Path.Combine(Application.temporaryCachePath, $"{k_ModeLayoutKeyName}-{GetModeId(args.nextIndex)}.wlt"); if (File.Exists(modeLayoutPath)) { WindowLayout.LoadWindowLayout(modeLayoutPath, false, false); } else { var layouts = GetModeDataSection(args.nextIndex, k_LayoutsSectionName) as IList <object>; if (layouts != null && layouts.Count > 0) { var layoutPath = layouts[0] as string; if (layoutPath != null) { WindowLayout.LoadWindowLayout(layoutPath, false, false); } } } WindowLayout.ReloadWindowLayoutMenu(); }
static void SaveWindowLayout() { WindowLayout.SaveWindowLayout(userPrefProfilerLayoutPath); }