public static void SearchForType(System.Type type) { UnityEngine.Object[] objArray = UnityEngine.Resources.FindObjectsOfTypeAll(typeof(SceneHierarchyWindow)); SceneHierarchyWindow window = (objArray.Length <= 0) ? null : (objArray[0] as SceneHierarchyWindow); if (window != null) { s_HierarchyWindow = window; if ((type == null) || (type == typeof(GameObject))) { s_FocusType = null; window.ClearSearchFilter(); } else { s_FocusType = type; if (window.searchMode == SearchableEditorWindow.SearchMode.Name) { window.searchMode = SearchableEditorWindow.SearchMode.All; } window.SetSearchFilter("t:" + type.Name, window.searchMode, false); window.hasSearchFilterFocus = true; } } else { s_FocusType = null; } }
public static void SearchForType(Type type) { UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll(typeof(SceneHierarchyWindow)); SceneHierarchyWindow sceneHierarchyWindow = (array.Length <= 0) ? null : (array[0] as SceneHierarchyWindow); if (sceneHierarchyWindow) { SceneModeUtility.s_HierarchyWindow = sceneHierarchyWindow; if (type == null || type == typeof(GameObject)) { SceneModeUtility.s_FocusType = null; sceneHierarchyWindow.ClearSearchFilter(); } else { SceneModeUtility.s_FocusType = type; if (sceneHierarchyWindow.searchMode == SearchableEditorWindow.SearchMode.Name) { sceneHierarchyWindow.searchMode = SearchableEditorWindow.SearchMode.All; } sceneHierarchyWindow.SetSearchFilter("t:" + type.Name, sceneHierarchyWindow.searchMode, false); sceneHierarchyWindow.hasSearchFilterFocus = true; } } else { SceneModeUtility.s_FocusType = null; } }
public static void SearchForType(Type type) { Object[] wins = Resources.FindObjectsOfTypeAll(typeof(SceneHierarchyWindow)); SceneHierarchyWindow win = wins.Length > 0 ? (wins[0] as SceneHierarchyWindow) : null; if (win) { s_HierarchyWindow = win; if (type == null || type == typeof(GameObject)) { s_FocusType = null; win.ClearSearchFilter(); } else { s_FocusType = type; if (win.searchMode == SearchableEditorWindow.SearchMode.Name) { win.searchMode = SearchableEditorWindow.SearchMode.All; } win.SetSearchFilter("t:" + type.Name, win.searchMode, false); win.hasSearchFilterFocus = true; } } else { s_FocusType = null; } }
private bool IsValidHierarchyInstanceID(int instanceID) { bool flag = SceneHierarchyWindow.IsSceneHeaderInHierarchyWindow(EditorSceneManager.GetSceneByHandle(instanceID)); bool flag2 = InternalEditorUtility.GetClassIDWithoutLoadingObject(instanceID) == this.kGameObjectClassID; return(flag || flag2); }
private bool IsValidHierarchyInstanceID(int instanceID) { bool isScene = SceneHierarchyWindow.IsSceneHeaderInHierarchyWindow(EditorSceneManager.GetSceneByHandle(instanceID)); bool isGameObject = InternalEditorUtility.GetTypeWithoutLoadingObject(instanceID) == typeof(GameObject); return(isScene || isGameObject); }
internal static void RebuildStageHeaderInAll() { var sceneHierarchyWindows = SceneHierarchyWindow.GetAllSceneHierarchyWindows(); foreach (SceneHierarchyWindow sceneHierarchyWindow in sceneHierarchyWindows) { sceneHierarchyWindow.RebuildStageHeader(); } }
internal static void ReloadAllHierarchyWindows() { var sceneHierarchyWindows = SceneHierarchyWindow.GetAllSceneHierarchyWindows(); foreach (SceneHierarchyWindow sceneHierarchyWindow in sceneHierarchyWindows) { sceneHierarchyWindow.ReloadData(); } }
public override void OnEnable() { base.OnEnable(); base.titleContent = base.GetLocalizedTitleContent(); SceneHierarchyWindow.s_SceneHierarchyWindow.Add(this); EditorApplication.projectWindowChanged = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.projectWindowChanged, new EditorApplication.CallbackFunction(this.ReloadData)); EditorApplication.searchChanged = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.searchChanged, new EditorApplication.CallbackFunction(this.SearchChanged)); SceneHierarchyWindow.s_LastInteractedHierarchy = this; }
static void RestoreExandedStateFromFileIDs(SceneHierarchyWindow hierarchy, StageNavigationItem item, List <UInt64> expandedGameObjectFileIDs, UInt64 lastClickedFileID) { var searchRoot = item.prefabStage.prefabContentsRoot; var fileIDToInstanceIDMapper = new FileIDToInstanceIDMapper(searchRoot.transform, expandedGameObjectFileIDs, lastClickedFileID); hierarchy.sceneHierarchy.treeViewState.lastClickedID = fileIDToInstanceIDMapper.instanceID; hierarchy.sceneHierarchy.treeViewState.expandedIDs = fileIDToInstanceIDMapper.instanceIDs; hierarchy.sceneHierarchy.treeViewState.expandedIDs.Sort(); // required to be sorted (see TreeViewState) }
private void RepaintSceneHierarchy() { List <SceneHierarchyWindow> sceneUIs = SceneHierarchyWindow.GetAllSceneHierarchyWindows(); foreach (SceneHierarchyWindow sceneUI in sceneUIs) { sceneUI.Repaint(); } }
public static void RepaintHierarchyWindow() { UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll(typeof(SceneHierarchyWindow)); for (int i = 0; i < array.Length; i++) { SceneHierarchyWindow sceneHierarchyWindow = (SceneHierarchyWindow)array[i]; sceneHierarchyWindow.Repaint(); } }
private void RepaintSceneHierarchy() { List <SceneHierarchyWindow> allSceneHierarchyWindows = SceneHierarchyWindow.GetAllSceneHierarchyWindows(); foreach (SceneHierarchyWindow current in allSceneHierarchyWindows) { current.Repaint(); } }
public static void DirtyHierarchyWindowSorting() { UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll(typeof(SceneHierarchyWindow)); for (int i = 0; i < array.Length; i++) { SceneHierarchyWindow sceneHierarchyWindow = (SceneHierarchyWindow)array[i]; sceneHierarchyWindow.DirtySortingMethods(); } }
internal void SwitchToEditMode() { this.m_EditMode = AvatarEditor.EditMode.Starting; this.ChangeInspectorLock(true); this.sceneSetup = EditorSceneManager.GetSceneManagerSetup(); EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects).name = "Avatar Configuration"; this.m_GameObject = UnityEngine.Object.Instantiate <GameObject>(this.prefab); if (base.serializedObject.FindProperty("m_OptimizeGameObjects").boolValue) { AnimatorUtility.DeoptimizeTransformHierarchy(this.m_GameObject); } Dictionary <Transform, bool> modelBones = AvatarSetupTool.GetModelBones(this.m_GameObject.transform, true, null); AvatarSetupTool.BoneWrapper[] humanBones = AvatarSetupTool.GetHumanBones(base.serializedObject, modelBones); this.m_ModelBones = AvatarSetupTool.GetModelBones(this.m_GameObject.transform, false, humanBones); Selection.activeObject = this.m_GameObject; UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll(typeof(SceneHierarchyWindow)); for (int i = 0; i < array.Length; i++) { SceneHierarchyWindow sceneHierarchyWindow = (SceneHierarchyWindow)array[i]; sceneHierarchyWindow.SetExpandedRecursive(this.m_GameObject.GetInstanceID(), true); } this.CreateEditor(); this.m_EditMode = AvatarEditor.EditMode.Editing; this.m_SceneStates = new List <AvatarEditor.SceneStateCache>(); IEnumerator enumerator = SceneView.sceneViews.GetEnumerator(); try { while (enumerator.MoveNext()) { SceneView sceneView = (SceneView)enumerator.Current; this.m_SceneStates.Add(new AvatarEditor.SceneStateCache { state = new SceneView.SceneViewState(sceneView.sceneViewState), view = sceneView }); sceneView.sceneViewState.showFlares = false; sceneView.sceneViewState.showMaterialUpdate = false; sceneView.sceneViewState.showFog = false; sceneView.sceneViewState.showSkybox = false; sceneView.sceneViewState.showImageEffects = false; sceneView.sceneViewState.showParticleSystems = false; sceneView.FrameSelected(); } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } }
public static void PingObject(int targetInstanceID) { foreach (SceneHierarchyWindow current in SceneHierarchyWindow.GetAllSceneHierarchyWindows()) { bool ping = true; current.FrameObject(targetInstanceID, ping); } foreach (ProjectBrowser current2 in ProjectBrowser.GetAllProjectBrowsers()) { bool ping2 = true; current2.FrameObject(targetInstanceID, ping2); } }
private List <int> GetSelectedGameObjects() { List <int> intList = new List <int>(); foreach (int handle in this.m_TreeView.GetSelection()) { if (!SceneHierarchyWindow.IsSceneHeaderInHierarchyWindow(EditorSceneManager.GetSceneByHandle(handle))) { intList.Add(handle); } } return(intList); }
static void RepaintHierarchyWindowsAfterPaste() { if (SceneHierarchyWindow.lastInteractedHierarchyWindow == null) { return; } foreach (var win in SceneHierarchyWindow.GetAllSceneHierarchyWindows()) { win.Repaint(); } }
public static void PingObject(int targetInstanceID) { foreach (SceneHierarchyWindow window in SceneHierarchyWindow.GetAllSceneHierarchyWindows()) { bool ping = true; window.FrameObject(targetInstanceID, ping); } foreach (ProjectBrowser browser in ProjectBrowser.GetAllProjectBrowsers()) { bool flag2 = true; browser.FrameObject(targetInstanceID, flag2); } }
void LoadHierarchyState(SceneHierarchyWindow hierarchy, StageNavigationItem stage) { if (stage == null) { return; } var state = GetStoredHierarchyState(hierarchy, stage); if (state != null) { state.LoadStateIntoHierarchy(hierarchy, stage); } }
public void OnDestroy() { if (SceneHierarchyWindow.s_LastInteractedHierarchy == this) { SceneHierarchyWindow.s_LastInteractedHierarchy = null; foreach (SceneHierarchyWindow current in SceneHierarchyWindow.s_SceneHierarchyWindow) { if (current != this) { SceneHierarchyWindow.s_LastInteractedHierarchy = current; } } } }
public override void OnEnable() { base.OnEnable(); s_LastInteractedHierarchy = this; s_SceneHierarchyWindows.Add(this); m_SceneHierarchy.position = treeViewRect; // ensure SceneHierarchy has a valid rect before initializing in OnEnable m_SceneHierarchy.OnEnable(); m_StageHandling = new SceneHierarchyStageHandling(this); m_StageHandling.OnEnable(); titleContent = GetLocalizedTitleContent(); }
internal void SwitchToEditMode() { this.m_EditMode = AvatarEditor.EditMode.Starting; this.ChangeInspectorLock(true); this.sceneSetup = EditorSceneManager.GetSceneManagerSetup(); EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects).name = "Avatar Configuration"; this.m_GameObject = UnityEngine.Object.Instantiate <GameObject>(this.prefab); if (base.serializedObject.FindProperty("m_OptimizeGameObjects").boolValue) { AnimatorUtility.DeoptimizeTransformHierarchy(this.m_GameObject); } Animator component = this.m_GameObject.GetComponent <Animator>(); if (component != null && component.runtimeAnimatorController == null) { AnimatorController animatorController = new AnimatorController(); animatorController.hideFlags = HideFlags.DontSave; animatorController.AddLayer("preview"); animatorController.layers[0].stateMachine.hideFlags = HideFlags.DontSave; component.runtimeAnimatorController = animatorController; } Dictionary <Transform, bool> modelBones = AvatarSetupTool.GetModelBones(this.m_GameObject.transform, true, null); AvatarSetupTool.BoneWrapper[] humanBones = AvatarSetupTool.GetHumanBones(base.serializedObject, modelBones); this.m_ModelBones = AvatarSetupTool.GetModelBones(this.m_GameObject.transform, false, humanBones); Selection.activeObject = this.m_GameObject; UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll(typeof(SceneHierarchyWindow)); for (int i = 0; i < array.Length; i++) { SceneHierarchyWindow sceneHierarchyWindow = (SceneHierarchyWindow)array[i]; sceneHierarchyWindow.SetExpandedRecursive(this.m_GameObject.GetInstanceID(), true); } this.CreateEditor(); this.m_EditMode = AvatarEditor.EditMode.Editing; this.m_SceneStates = new List <AvatarEditor.SceneStateCache>(); foreach (SceneView sceneView in SceneView.sceneViews) { this.m_SceneStates.Add(new AvatarEditor.SceneStateCache { state = new SceneView.SceneViewState(sceneView.m_SceneViewState), view = sceneView }); sceneView.m_SceneViewState.showFlares = false; sceneView.m_SceneViewState.showMaterialUpdate = false; sceneView.m_SceneViewState.showFog = false; sceneView.m_SceneViewState.showSkybox = false; sceneView.m_SceneViewState.showImageEffects = false; sceneView.FrameSelected(); } }
void OnGUI() { Rect sceneHierarchyRect = new Rect(0, 0, position.width, position.height); Event evt = Event.current; if (evt.type == EventType.MouseDown && sceneHierarchyRect.Contains(evt.mousePosition)) { s_LastInteractedHierarchy = this; } DoToolbarLayout(); DoSceneHierarchy(); ExecuteCommands(); }
private void ItemContextClick(int contextClickedItemID) { Event.current.Use(); GenericMenu menu = new GenericMenu(); if (SceneHierarchyWindow.IsSceneHeaderInHierarchyWindow(EditorSceneManager.GetSceneByHandle(contextClickedItemID))) { this.CreateMultiSceneHeaderContextClick(menu, contextClickedItemID); } else { this.CreateGameObjectContextClick(menu, contextClickedItemID); } menu.ShowAsContext(); }
public void SaveStateFromHierarchy(SceneHierarchyWindow hierarchy, Stage stage) { var lastClickedGameObject = EditorUtility.InstanceIDToObject(hierarchy.sceneHierarchy.treeViewState.lastClickedID) as GameObject; m_LastClickedInstanceID = lastClickedGameObject != null?lastClickedGameObject.GetInstanceID() : 0; m_ExpandedSceneGameObjectInstanceIDs = hierarchy.sceneHierarchy.treeViewState.expandedIDs; m_ScrollY = hierarchy.sceneHierarchy.treeViewState.scrollPos.y; if (SceneHierarchy.s_DebugPersistingExpandedState) { DebugLog("Saving", stage); } }
public void SaveStateFromHierarchy(SceneHierarchyWindow hierarchy, Stage stage) { var lastClickedGameObject = EditorUtility.InstanceIDToObject(hierarchy.sceneHierarchy.treeViewState.lastClickedID) as GameObject; m_LastClickedFileID = lastClickedGameObject != null?Unsupported.GetOrGenerateFileIDHint(lastClickedGameObject) : 0; m_ExpandedPrefabGameObjectFileIDs = GetExpandedGameObjectFileIDs(hierarchy); m_ScrollY = hierarchy.sceneHierarchy.treeViewState.scrollPos.y; if (SceneHierarchy.s_DebugPersistingExpandedState) { DebugLog("Saving", stage); } }
private List <Scene> GetDraggedScenes(List <int> draggedItemIDs) { List <Scene> list = new List <Scene>(); foreach (int current in draggedItemIDs) { Scene sceneByHandle = EditorSceneManager.GetSceneByHandle(current); if (!SceneHierarchyWindow.IsSceneHeaderInHierarchyWindow(sceneByHandle)) { return(null); } list.Add(sceneByHandle); } return(list); }
static List <UInt64> GetExpandedGameObjectFileIDs(SceneHierarchyWindow hierarchy) { var fileIDs = new List <UInt64>(); var expandedGameObjects = hierarchy.sceneHierarchy.GetExpandedGameObjects(); foreach (var go in expandedGameObjects) { UInt64 fileID = GetOrGenerateFileID(go); if (fileID != 0) { fileIDs.Add(fileID); } } return(fileIDs); }
internal static void Place(GameObject go, GameObject parent, bool ignoreSceneViewPosition = true) { Transform defaultObjectTransform = SceneView.GetDefaultParentObjectIfSet(); if (parent != null) { // At this point, RecordStructureChange is already ongoing (from the CreatePrimitive call through the CreateAndPlacePrimitive method). We need to flush the stack to finalise the RecordStructureChange before the // following SetTransformParent call takes place. Undo.FlushTrackedObjects(); SetGameObjectParent(go, parent.transform); } else if (defaultObjectTransform != null) { // At this point, RecordStructureChange is already ongoing (from the CreatePrimitive call through the CreateAndPlacePrimitive method). We need to flush the stack to finalise the RecordStructureChange before the // following SetTransformParent call takes place. Undo.FlushTrackedObjects(); SetGameObjectParent(go, defaultObjectTransform); } else { // When creating a 3D object without a parent, this option puts it at the world origin instead of scene pivot. if (placeObjectsAtWorldOrigin) { go.transform.position = Vector3.zero; } else if (ignoreSceneViewPosition) { SceneView.PlaceGameObjectInFrontOfSceneView(go); } StageUtility.PlaceGameObjectInCurrentStage(go); // may change parent } // Only at this point do we know the actual parent of the object and can modify its name accordingly. GameObjectUtility.EnsureUniqueNameForSibling(go); Undo.SetCurrentGroupName("Create " + go.name); var sh = SceneHierarchyWindow.GetSceneHierarchyWindowToFocusForNewGameObjects(); if (sh != null) { sh.Focus(); } Selection.activeGameObject = go; }
void SaveHierarchyState(SceneHierarchyWindow hierarchyWindow, StageNavigationItem stage) { if (stage == null) { return; } string key = StageUtility.CreateWindowAndStageIdentifier(hierarchyWindow.windowGUID, stage); var state = m_StateCache.GetState(key); if (state == null) { state = new SceneHierarchyState(); } state.SaveStateFromHierarchy(hierarchyWindow, stage); m_StateCache.SetState(key, state); }
public override void OnEnable() { base.OnEnable(); this.titleContent = this.GetLocalizedTitleContent(); SceneHierarchyWindow.s_SceneHierarchyWindow.Add(this); EditorApplication.projectWindowChanged += new EditorApplication.CallbackFunction(this.ReloadData); EditorApplication.searchChanged += new EditorApplication.CallbackFunction(this.SearchChanged); SceneHierarchyWindow.s_LastInteractedHierarchy = this; }
private void SetAsLastInteractedHierarchy() { SceneHierarchyWindow.s_LastInteractedHierarchy = this; }
public void OnDestroy() { if (!((UnityEngine.Object) SceneHierarchyWindow.s_LastInteractedHierarchy == (UnityEngine.Object) this)) return; SceneHierarchyWindow.s_LastInteractedHierarchy = (SceneHierarchyWindow) null; using (List<SceneHierarchyWindow>.Enumerator enumerator = SceneHierarchyWindow.s_SceneHierarchyWindow.GetEnumerator()) { while (enumerator.MoveNext()) { SceneHierarchyWindow current = enumerator.Current; if ((UnityEngine.Object) current != (UnityEngine.Object) this) SceneHierarchyWindow.s_LastInteractedHierarchy = current; } } }