-
-
Save hzi-dev/08acfd17eb315f93e4aaa0c8ee56eea3 to your computer and use it in GitHub Desktop.
Revisions
-
yasirkula revised this gist
Feb 7, 2020 . 1 changed file with 12 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -57,9 +57,18 @@ private static void CollapseGameObjects( MenuCommand command ) } List<GameObject> rootGameObjects = new List<GameObject>(); #if UNITY_2018_3_OR_NEWER // Check if a prefab stage is currently open var prefabStage = UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage(); if( prefabStage != null && prefabStage.stageHandle.IsValid() ) rootGameObjects.Add( prefabStage.prefabContentsRoot ); else #endif { int sceneCount = SceneManager.sceneCount; for( int i = 0; i < sceneCount; i++ ) rootGameObjects.AddRange( SceneManager.GetSceneAt( i ).GetRootGameObjects() ); } if( rootGameObjects.Count > 0 ) { -
yasirkula revised this gist
Jan 21, 2020 . 1 changed file with 20 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,27 +9,27 @@ public static class EditorCollapseAll private static int wait = 0; private static int undoIndex; [MenuItem( "Assets/Collapse All", priority = 1000 )] public static void CollapseFolders() { FileSystemInfo[] rootItems = new DirectoryInfo( Application.dataPath ).GetFileSystemInfos(); List<Object> rootItemsList = new List<Object>( rootItems.Length ); for( int i = 0; i < rootItems.Length; i++ ) { Object asset = AssetDatabase.LoadAssetAtPath<Object>( "Assets/" + rootItems[i].Name ); if( asset != null ) rootItemsList.Add( asset ); } if( rootItemsList.Count > 0 ) { Undo.IncrementCurrentGroup(); Selection.objects = Selection.objects; undoIndex = Undo.GetCurrentGroup(); EditorUtility.FocusProjectWindow(); Selection.objects = rootItemsList.ToArray(); EditorApplication.update -= CollapseHelper; EditorApplication.update += CollapseHelper; @@ -74,6 +74,17 @@ private static void CollapseGameObjects( MenuCommand command ) } } [MenuItem( "CONTEXT/Component/Collapse All", priority = 1400 )] private static void CollapseComponents( MenuCommand command ) { // Credit: https://forum.unity.com/threads/is-it-possible-to-fold-a-component-from-script-inspector-view.296333/#post-2353538 ActiveEditorTracker tracker = ActiveEditorTracker.sharedTracker; for( int i = 0, length = tracker.activeEditors.Length; i < length; i++ ) tracker.SetVisible( i, 0 ); EditorWindow.focusedWindow.Repaint(); } private static void CollapseHelper() { if( wait < 1 ) // Increase the number if script doesn't always work -
yasirkula revised this gist
Oct 24, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -85,7 +85,7 @@ private static void CollapseHelper() EditorWindow focusedWindow = EditorWindow.focusedWindow; if( focusedWindow != null ) focusedWindow.SendEvent( new Event { keyCode = KeyCode.LeftArrow, type = EventType.KeyDown, alt = true } ); Undo.RevertAllDownToGroup( undoIndex ); } -
yasirkula revised this gist
Oct 21, 2019 . 1 changed file with 24 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,13 +30,32 @@ public static void CollapseFolders() EditorUtility.FocusProjectWindow(); Selection.objects = rootDirectoriesList.ToArray(); EditorApplication.update -= CollapseHelper; EditorApplication.update += CollapseHelper; } } public static void CollapseGameObjects() { EditorApplication.update -= CollapseGameObjects; CollapseGameObjects( new MenuCommand( null ) ); } [MenuItem( "GameObject/Collapse All", priority = 40 )] private static void CollapseGameObjects( MenuCommand command ) { // This happens when this button is clicked via hierarchy's right click context menu // and is called once for each object in the selection. We don't want that, we want // the function to be called only once if( command.context ) { EditorApplication.update -= CollapseGameObjects; EditorApplication.update += CollapseGameObjects; return; } List<GameObject> rootGameObjects = new List<GameObject>(); int sceneCount = SceneManager.sceneCount; for( int i = 0; i < sceneCount; i++ ) @@ -47,8 +66,10 @@ public static void CollapseGameObjects() Undo.IncrementCurrentGroup(); Selection.objects = Selection.objects; undoIndex = Undo.GetCurrentGroup(); Selection.objects = rootGameObjects.ToArray(); EditorApplication.update -= CollapseHelper; EditorApplication.update += CollapseHelper; } } @@ -59,13 +80,13 @@ private static void CollapseHelper() wait++; else { EditorApplication.update -= CollapseHelper; wait = 0; EditorWindow focusedWindow = EditorWindow.focusedWindow; if( focusedWindow != null ) focusedWindow.SendEvent( new Event { keyCode = KeyCode.LeftArrow, type = EventType.keyDown, alt = true } ); Undo.RevertAllDownToGroup( undoIndex ); } } -
yasirkula revised this gist
Oct 29, 2017 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,9 +23,12 @@ public static void CollapseFolders() if( rootDirectoriesList.Count > 0 ) { Undo.IncrementCurrentGroup(); Selection.objects = Selection.objects; undoIndex = Undo.GetCurrentGroup(); EditorUtility.FocusProjectWindow(); Selection.objects = rootDirectoriesList.ToArray(); EditorApplication.update += CollapseHelper; } @@ -41,6 +44,8 @@ public static void CollapseGameObjects() if( rootGameObjects.Count > 0 ) { Undo.IncrementCurrentGroup(); Selection.objects = Selection.objects; undoIndex = Undo.GetCurrentGroup(); Selection.objects = rootGameObjects.ToArray(); -
yasirkula revised this gist
Oct 29, 2017 . No changes.There are no files selected for viewing
-
yasirkula revised this gist
Oct 29, 2017 . No changes.There are no files selected for viewing
-
yasirkula revised this gist
Oct 29, 2017 . No changes.There are no files selected for viewing
-
yasirkula renamed this gist
Oct 29, 2017 . 1 changed file with 28 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,14 +2,15 @@ using System.IO; using UnityEditor; using UnityEngine; using UnityEngine.SceneManagement; public static class EditorCollapseAll { private static int wait = 0; private static int undoIndex; [MenuItem( "Assets/Collapse Folders", priority = 1000 )] public static void CollapseFolders() { DirectoryInfo[] rootDirectories = new DirectoryInfo( Application.dataPath ).GetDirectories(); List<Object> rootDirectoriesList = new List<Object>( rootDirectories.Length ); @@ -22,14 +23,31 @@ public static void CollapseAll() if( rootDirectoriesList.Count > 0 ) { undoIndex = Undo.GetCurrentGroup(); EditorUtility.FocusProjectWindow(); Selection.objects = rootDirectoriesList.ToArray(); EditorApplication.update += CollapseHelper; } } [MenuItem( "GameObject/Collapse All", priority = 40 )] public static void CollapseGameObjects() { List<GameObject> rootGameObjects = new List<GameObject>(); int sceneCount = SceneManager.sceneCount; for( int i = 0; i < sceneCount; i++ ) rootGameObjects.AddRange( SceneManager.GetSceneAt( i ).GetRootGameObjects() ); if( rootGameObjects.Count > 0 ) { undoIndex = Undo.GetCurrentGroup(); Selection.objects = rootGameObjects.ToArray(); EditorApplication.update += CollapseHelper; } } private static void CollapseHelper() { if( wait < 1 ) // Increase the number if script doesn't always work @@ -38,10 +56,12 @@ private static void CollapseHelper() { wait = 0; EditorWindow focusedWindow = EditorWindow.focusedWindow; if( focusedWindow != null ) focusedWindow.SendEvent( new Event { keyCode = KeyCode.LeftArrow, type = EventType.keyDown, alt = true } ); EditorApplication.update -= CollapseHelper; Undo.RevertAllDownToGroup( undoIndex ); } } } -
yasirkula revised this gist
Oct 29, 2017 . No changes.There are no files selected for viewing
-
yasirkula created this gist
Oct 29, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ using System.Collections.Generic; using System.IO; using UnityEditor; using UnityEngine; public static class EditorCollapseFolders { private static int wait = 0; private static Object[] prevSelection; [MenuItem( "Assets/Collapse Folders", priority = 1000 )] public static void CollapseAll() { DirectoryInfo[] rootDirectories = new DirectoryInfo( Application.dataPath ).GetDirectories(); List<Object> rootDirectoriesList = new List<Object>( rootDirectories.Length ); for( int i = 0; i < rootDirectories.Length; i++ ) { Object directoryObj = AssetDatabase.LoadAssetAtPath<Object>( "Assets/" + rootDirectories[i].Name ); if( directoryObj != null ) rootDirectoriesList.Add( directoryObj ); } if( rootDirectoriesList.Count > 0 ) { prevSelection = Selection.objects; EditorUtility.FocusProjectWindow(); Selection.objects = rootDirectoriesList.ToArray(); EditorApplication.update += CollapseHelper; } } private static void CollapseHelper() { if( wait < 1 ) // Increase the number if script doesn't always work wait++; else { wait = 0; EditorWindow.focusedWindow.SendEvent( new Event { keyCode = KeyCode.LeftArrow, type = EventType.keyDown, alt = true } ); EditorApplication.update -= CollapseHelper; Selection.objects = prevSelection; } } }