static void SaveSetup() { string path = EditorUtility.SaveFilePanelInProject("Save EditorSceneSetup", "New EditorSceneSetup", "asset", "Save EditorSceneSetup?"); if (path != string.Empty) { EditorSceneSetup setup = GetCurrentSetup(); AssetDatabase.CreateAsset(setup, path); } }
public static void RestoreSetup(EditorSceneSetup editorSetup) { SceneSetup[] setups = new SceneSetup[editorSetup.LoadedScenes.Length]; for (int i = 0; i < setups.Length; i++) { setups[i] = new SceneSetup(); string path = AssetDatabase.GetAssetPath(editorSetup.LoadedScenes[i].Scene); setups[i].path = path; setups[i].isLoaded = editorSetup.LoadedScenes[i].Loaded; setups[i].isActive = (editorSetup.ActiveScene == i); } EditorSceneManager.RestoreSceneManagerSetup(setups); }
void LoadSceneSetup(EditorSceneSetup setup) { try { EditorUtility.DisplayProgressBar("Discover", $"Opening {setup.name}...", 0.9f); forceGlobal = false; EditorSceneSetup.RestoreSetup(setup); } catch { Debug.LogError($"Could not load EditorSceneSetup : {setup.name}"); } finally { EditorUtility.ClearProgressBar(); UpdateDiscoverObjects(); } }
static bool OnOpenAsset(int instanceID, int line) { var obj = EditorUtility.InstanceIDToObject(instanceID); if (obj is EditorSceneSetup) { EditorSceneSetup setup = (EditorSceneSetup)obj; int active = setup.ActiveScene; try { EditorUtility.DisplayProgressBar("Loading Scenes", string.Format("Loading Scene Setup {0}....", setup.name), 1.0f); RestoreSetup(setup); } finally { EditorUtility.ClearProgressBar(); } return(true); } return(false); }
void UpdateDiscoverObjectsOnLoadSetup(EditorSceneSetup setup) { forceGlobal = false; UpdateDiscoverObjects(); }
static void ActionButtonGUI(UnityEngine.Object target) { if (target == null) { EditorGUI.BeginDisabledGroup(true); GUILayout.Button("(No Object)"); EditorGUI.EndDisabledGroup(); return; } Type t = target.GetType(); if (t == typeof(GameObject)) { GameObject go = target as GameObject; if (GUILayout.Button(" Select ", DiscoverWindow.Styles.buttonLeft)) { Selection.activeObject = go; } if (PrefabUtility.GetPrefabAssetType(go) == PrefabAssetType.NotAPrefab) { if (GUILayout.Button(" Go to ", DiscoverWindow.Styles.buttonRight)) { Selection.activeObject = go; SceneView.lastActiveSceneView.FrameSelected(); } } else { if (GUILayout.Button(" Open ", DiscoverWindow.Styles.buttonRight)) { AssetDatabase.OpenAsset(go); } } } else if (t == typeof(Discover)) { if (GUILayout.Button("Discover")) { var discover = target as Discover; Selection.activeGameObject = discover.gameObject; DiscoverWindow.SelectDiscover(discover); } } else if (t == typeof(VisualEffectAsset)) { if (GUILayout.Button("Open VFX Graph")) { VisualEffectAsset graph = target as VisualEffectAsset; AssetDatabase.OpenAsset(graph); } } else if (t == typeof(Animation)) { if (GUILayout.Button("Open Animation")) { Animation animation = target as Animation; AssetDatabase.OpenAsset(animation); } } else if (t == typeof(TimelineAsset)) { if (GUILayout.Button("Open Timeline")) { TimelineAsset timeline = target as TimelineAsset; AssetDatabase.OpenAsset(timeline); } } else if (t == typeof(PlayableDirector)) { if (GUILayout.Button("Open Director")) { PlayableDirector director = target as PlayableDirector; AssetDatabase.OpenAsset(director.playableAsset); Selection.activeObject = director.gameObject; } } else if (t == typeof(Shader)) { if (GUILayout.Button("Open Shader")) { Shader shader = target as Shader; AssetDatabase.OpenAsset(shader); } } else if (t == typeof(SceneAsset)) { if (GUILayout.Button("Open Scene")) { SceneAsset scene = target as SceneAsset; AssetDatabase.OpenAsset(scene); } } else if (t == typeof(EditorSceneSetup)) { if (GUILayout.Button("Open Scenes")) { EditorSceneSetup scene = target as EditorSceneSetup; AssetDatabase.OpenAsset(scene); } } else { if (GUILayout.Button("Select")) { Selection.activeObject = target; } } }
void ReloadSetup(EditorSceneSetup setup) { ReloadCallHierarchy(); }