/// <summary> /// Save the current window layout. /// </summary> /// <param name="safe">Should the layout be saved as a backup?</param> public static void SaveLayout(bool safe) { try { ReflectionUtility.FindClass("UnityEditor.WindowLayout").InvokeMethod("SaveWindowLayout", safe ? SAFE_LAYOUT_PATH : TEMP_LAYOUT_PATH); } catch (Exception e) { Debug.LogError("Failed to save current layout: " + e); } }
static FullscreenPreferences() { ReloadPreferences(); preferenceWindowType = ReflectionUtility.FindClass("UnityEditor.PreferencesWindow"); EditorApplication.update += () => { if (!lastWindow && PreferenceWindow) { FullscreenUtility.WaitFrames(2, () => SetCustomIconOnPreferences(PreferenceWindow)); } }; }
private static void OpenSettings() { try { ReflectionUtility.FindClass("UnityEditor.PreferencesWindow").InvokeMethod("ShowPreferencesWindow"); FullscreenUtility.WaitFrames(1, () => { var index = GetIndexOnPreferences(PreferenceWindow); PreferenceWindow.SetPropertyValue("selectedSectionIndex", index); }); } catch (Exception e) { Debug.LogWarning("Failed to open settings, you can find them under \"" + PREFERENCES_MENU_ITEM + "\""); Debug.LogException(e); } }
/// <summary> /// Load a layout saved previously and then deletes the file. /// </summary> /// <param name="safe">Should we load the backup layout?</param> public static void LoadLayout(bool safe) { try { if (!File.Exists(safe ? SAFE_LAYOUT_PATH : TEMP_LAYOUT_PATH)) { return; } using (new SupressLog()) //Supress the following errors about failing to destroy views. ReflectionUtility.FindClass("UnityEditor.WindowLayout").InvokeMethod("LoadWindowLayout", safe ? SAFE_LAYOUT_PATH : TEMP_LAYOUT_PATH, true); File.Delete(safe ? SAFE_LAYOUT_PATH : TEMP_LAYOUT_PATH); } catch (Exception e) { InternalEditorUtility.LoadDefaultLayout(); Debug.LogException(e); Debug.LogError("Error while loading the previous layout, the default layout was loaded instead"); } }
static FullscreenPreferences() { ReloadPreferences(); preferenceWindowType = ReflectionUtility.FindClass("UnityEditor.PreferencesWindow"); }
public static EditorWindow[] GetGameViews() { return(ReflectionUtility.FindClass("UnityEditor.GameView").GetFieldValue <IList>("s_GameViews").Cast <EditorWindow>().ToArray()); }
public static EditorWindow GetMainGameView() { return(ReflectionUtility.FindClass("UnityEditor.GameView").InvokeMethod <EditorWindow>("GetMainGameView")); }