Search Unity

FREE: Editor enhancements - Extensions in project window! Components in heirarchy!

Discussion in 'Assets and Asset Store' started by Tenebrous, Aug 31, 2012.

  1. Tenebrous

    Tenebrous

    Volunteer Moderator Moderator

    Joined:
    Jul 25, 2011
    Posts:
    99
    HELLO!

    Over the past couple of days I worked on some editor enhancements to the Project and Heirarchy windows.



    Project Window
    * Shows file extensions (can be set to only show them when duplicate filenames are present)
    * Has a pop-up quick preview if you hold the mouse over an item
    * 'Useful' tooltips are also shown per item

    Heirarchy Window
    * Shows icons for each component on the gameobject, which can be disabled/enabled by clicking
    * Has a pop-up quick preview if you hold the mouse over a gameobject or one of it's components
    * 'Useful' tooltips are also shown per item and per component

    Settings
    There are some settings in Edit / Preferences / Project Window Heirarchy Window - however they're kinda broken at the moment. For example, you can set the Project Window not to show all the extensions, in which case it will only show them if there are two or more files with the same name :)

    Installation
    You can grab a ZIP of the code here: EditorEnhancements.zip - just copy the EditorEnhancements folder into your Assets folder. The bitbucket repository for the code is here.

    I have tested on Unity 3.5.5, and Unity 4b7.

    Please tell me how you get on with it, and if you want anything else added :)



    Versions
    1st Sep - Supports missing scripts better, no longer truncates icons, and toggling components via their icons is now undo-able.
    1st Sep B - Quick asset preview if you hover the mouse in the project window. Also strikeout hierarchy items if they're not visible in the scene view due to layer settings.
    5th Sep - Now has a quick preview window if you hover over gameobjects or their components in the hierarchy window.
     
    Last edited: Sep 5, 2012
    neonblitzer likes this.
  2. mmoDust

    mmoDust

    Joined:
    Jun 13, 2011
    Posts:
    17
    Works great, I love the Hierarchy one and being able to quickly shut off a part of an item for testing purposes.
     
  3. Tenebrous

    Tenebrous

    Volunteer Moderator Moderator

    Joined:
    Jul 25, 2011
    Posts:
    99
    Thanks for trying it out :) - I added Undo support for the toggling in the latest version.
     
  4. cram

    cram

    Joined:
    Jan 8, 2012
    Posts:
    21
    hey this works great! This should be native in unity!
    thanks! :)
     
  5. Tenebrous

    Tenebrous

    Volunteer Moderator Moderator

    Joined:
    Jul 25, 2011
    Posts:
    99
    You're welcome!
     
  6. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,395
    Tenebrous, you are the men!!! This is a great extension!
    Thanks a lot! :)
     
  7. nukeD

    nukeD

    Joined:
    Feb 12, 2009
    Posts:
    403
    Thanks a lot man! Very useful... very!

    EDIT:... but: when i click on your icons in the Heirarchy Window, they DO work, but Unity jumps from the scene view to game view.

     
    Last edited: Sep 1, 2012
  8. Tenebrous

    Tenebrous

    Volunteer Moderator Moderator

    Joined:
    Jul 25, 2011
    Posts:
    99
    Well spotted! I'll try and address this soon :)
     
  9. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,395
    Seems like in HierarchyWindow.cs the function
    Code (csharp):
    1. private static EditorWindow HeirarchyWindow
    doesn't really find the hierarchy window. In my case it was returning the Inspector window, so on toggle the focus jumps on the inspector. However, there's no need to change the focus on toggle, so you can remove that part from code or just comment it out like this:
    Code (csharp):
    1. if( GUI.Button( iconRect, new GUIContent( "", tooltip ), EditorStyles.label ) )
    2. {
    3.     c.SetEnabled( !c.GetEnabled() );
    4.     //heirarchyWindow.Focus();
    5.     //EditorApplication.RepaintHierarchyWindow();
    6.     return;
    7. }
    8.  
    But then the Inspector window doesn't update check boxes on collapsed components! Which is weird... There's an easy fix for that too. Near the end in function SetEnabled make sure you also call SetDirty like this:
    Code (csharp):
    1.         public static void SetEnabled( this Component pComponent, bool bNewValue )
    2.         {
    3.             if( pComponent == null )
    4.                 return;
    5.  
    6.             Undo.RegisterUndo( pComponent, bNewValue ? "Enable Component" : "Disable Component" );
    7.  
    8.             PropertyInfo p = pComponent.GetType().GetProperty( "enabled", typeof( bool ) );
    9.  
    10.             if (p != null)
    11.             {
    12.                 p.SetValue(pComponent, bNewValue, null);
    13.                 EditorUtility.SetDirty(pComponent.gameObject); // <- ADD THIS LINE
    14.             }
    15.         }
    16.  
     
  10. Tenebrous

    Tenebrous

    Volunteer Moderator Moderator

    Joined:
    Jul 25, 2011
    Posts:
    99
    Thanks for this :) I've already fixed the code to get hierachy window not actually getting the right window, and the same applied to the project window too. I've also gotten it to refresh properly on Unity4. Once I've added the SetDirty as well I'll commit the code to bitbucket :)

    Thanks :)
     
  11. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    693
    Wow....fantastic extension! Thanks!.
     
  12. Tenebrous

    Tenebrous

    Volunteer Moderator Moderator

    Joined:
    Jul 25, 2011
    Posts:
    99
    Just updated with: Quick asset preview if you hover the mouse in the project window. Also strikeout hierarchy items if they're not visible in the scene view due to layer settings.
     
  13. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    594
    Thanks Tenebrous. This looks great.
     
  14. diddykonga

    diddykonga

    Joined:
    Jun 9, 2011
    Posts:
    151
    If you plan to keep thinking and releasing awesome editor extensions, you should atleast put up a Donate button :)
     
  15. Tenebrous

    Tenebrous

    Volunteer Moderator Moderator

    Joined:
    Jul 25, 2011
    Posts:
    99
    OK! Here it is ->
     
  16. jedy

    jedy

    Joined:
    Aug 1, 2010
    Posts:
    578
    Great stuff!
    Never actually knew that I have those methods for the hierarchy and project panels :D
     
  17. Tenebrous

    Tenebrous

    Volunteer Moderator Moderator

    Joined:
    Jul 25, 2011
    Posts:
    99
    Nor did I, 'til AngryAnt mentioned them :)
     
  18. jedy

    jedy

    Joined:
    Aug 1, 2010
    Posts:
    578
    I've had a bit of a clash with the inspector, but after couple hours of reflection in vain I didn't find a decent way to customize things around there without rewriting most of the thing.
    Anyway I'll check AngryAnts talk and do some digging about what can be achieved and if all goes well I'll share any useful stuff ^^.
     
  19. Tenebrous

    Tenebrous

    Volunteer Moderator Moderator

    Joined:
    Jul 25, 2011
    Posts:
    99
    Oh this wasn't from his Unite stuff, it came up during a conversation in the IRC channel.
     
  20. jedy

    jedy

    Joined:
    Aug 1, 2010
    Posts:
    578
    I stumbled on a talk in tokyo for extending the editor maybe he mentioned something interesting there too.
     
  21. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,395
    Cool! It works nicely with my Favorites Tab :)

    $withEditorEnchancements.png

    There's one minor problem actually: quick preview takes the focus from Favorites view and sets it on Project view. That was probably done to make the focus stay on Project view, and you assumed Project view will be the only view displaying assets in a list. Now I'm not sure how hard would be to fix that, but I'll try something and I'll let you know.
     
  22. Tenebrous

    Tenebrous

    Volunteer Moderator Moderator

    Joined:
    Jul 25, 2011
    Posts:
    99
    Yeah absolutely, it was a bit of a hack. I can probably check to see which window the mouse is actually over though, and reset focus back to that one.
     
  23. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,068
    hey man, just wanted to say that this is just AWESOME work!. really really nice :)

    One thing that happens to me is that when I'm in another window and I move the mouse for some reason the Unity3D editor window pops up in front.

    anyways, awesome job!
     
  24. Tenebrous

    Tenebrous

    Volunteer Moderator Moderator

    Joined:
    Jul 25, 2011
    Posts:
    99
    Well, that's annoying! I'll try to fix that soon :)
     
  25. jocyf

    jocyf

    Joined:
    Jan 30, 2007
    Posts:
    252
    If you wanna use this utility and the UnityLock one (witch is what im doing for a while now) just edit the script HierarchyWindows.cs in the line 142.
    Replace the 16 value with a 32:

    iconRect.x = pDrawingRect.x + pDrawingRect.width - /*16*/ 32; // Change the position of the icon to the left so I can draw the icon of UnityLock in the right side.

    UnityLock link:
    http://forum.unity3d.com/threads/156016-Lock-your-game-objects-with-UnityLock-2-on-the-Asset-Store/page2?p=1320457#post1320457

    Cheers.


    EDIT : Here you have the utility working in Unity 4.2 with the changes already made:

    View attachment $Free Editor Enhacements for Unity 4.2.unitypackage
     
    Last edited: Aug 5, 2013
  26. Tenebrous

    Tenebrous

    Volunteer Moderator Moderator

    Joined:
    Jul 25, 2011
    Posts:
    99
    Thanks for that! And actually, in the latest version of my Editor Enhancements, it has a lock system built in! I added that on the 8th of June out of interest :)
     
  27. jocyf

    jocyf

    Joined:
    Jan 30, 2007
    Posts:
    252
    Didn't know that. I did it because i wanted to use some kind of lock feature as an adittion to your amazing utility and I actually use it a lot in my projects.

    Thanks for doing a such amazing work, it's one of those utilities that i always include in all my projects. It's really usefull.

    EDIT : I just test the last version and works great. Maybe a future improvement could be to do a recursive lock/unlock (of an object and all its childrens) using the right mouse button. That's what i did with UnityLock and it's super handy.
     
    Last edited: Aug 5, 2013
  28. jocyf

    jocyf

    Joined:
    Jan 30, 2007
    Posts:
    252
    I've created an recursive lock (using the right mouse button) in your last version of your Editor Enhacements.

    Changed the HierarchyWindow.cs in Draw function, line 241 (when starts the lock functionality):
    Code (csharp):
    1.  
    2.                         if( doLockIcon )
    3.                         {
    4.                             Rect r = pDrawingRect;
    5.                             r.x = r.x + r.width - 14;
    6.                             r.width = 12;
    7.  
    8.                             GUI.color = currentLock ? new Color(1,1,1,1) : new Color(1,1,1,0.4f);
    9.  
    10.                             bool newLock = GUI.Toggle( r, currentLock, "", (GUIStyle) "IN LockButton" );
    11.                             if( newLock != currentLock )
    12.                             {
    13.                                     // Changed to allow recursive lock/unlock.
    14.                                     // Warning: Doesn't detect a disabled child gameobject.
    15.                                     if (Event.current.button == 0)
    16.                                     {
    17.                                          if( newLock )
    18.                                             gameObject.hideFlags |= HideFlags.NotEditable;
    19.                                          else
    20.                                             gameObject.hideFlags -= HideFlags.NotEditable;
    21.                                     }          
    22.                                     else if (Event.current.button == 1)
    23.                                     {
    24.                                          Transform[] child = gameObject.GetComponentsInChildren<Transform>();
    25.                                          foreach (Transform childTransform in child){
    26.                                             if( newLock )
    27.                                                 childTransform.gameObject.hideFlags |= HideFlags.NotEditable;
    28.                                             else
    29.                                                 childTransform.gameObject.hideFlags -= HideFlags.NotEditable;
    30.                                          }
    31.                                     }
    32.                                    
    33.                             }
    34.                 // Added to reflect the change of gameobject's state (to disable/enable) in Inspector window.
    35.                             EditorUtility.SetDirty(gameObject);
    36.                
    37.                             pDrawingRect.width -= 14;
    38.                         }
    39.  
    Or here you have the modified version of that script:
    View attachment $HierarchyWindow.cs
     
    Last edited: Aug 6, 2013
  29. c_v

    c_v

    Joined:
    Nov 12, 2013
    Posts:
    4
    This stuff is awesome! Thank you!
     
  30. jocyf

    jocyf

    Joined:
    Jan 30, 2007
    Posts:
    252
    I got an error in the Project window, when its in some folder there are some files without any extesion.

    I solve it changing the Project Window.cs, line 257:

    Added the --> if( extension != "" ) to ensure that the extension exits.
     
  31. Crazydadz

    Crazydadz

    Joined:
    Mar 29, 2012
    Posts:
    50
    I've changed like 4 lines of code in the Common class to be able to use it in unity 5.2

    Here:
    Code (CSharp):
    1.         public static Texture GetMiniThumbnail( UnityEngine.Object obj )
    2.         {
    3.             return ( AssetPreview.GetMiniThumbnail( obj ) );
    4.         }
    5.  
    6.         public static Texture2D GetAssetPreview( UnityEngine.Object obj )
    7.         {
    8.             return ( AssetPreview.GetAssetPreview( obj ) );
    9.         }
    And here:
    Code (CSharp):
    1.         private static EditorWindow _projectWindow = null;
    2.         public static EditorWindow ProjectWindow
    3.         {
    4.             get
    5.             {
    6.                 _projectWindow = _projectWindow ?? GetWindowByName("UnityEditor.ProjectBrowser");
    7.                 return ( _projectWindow );
    8.             }
    9.         }
    10.  
    11.  
    12.         private static EditorWindow _hierarchyWindow = null;
    13.         public static EditorWindow HierarchyWindow
    14.         {
    15.             get
    16.             {
    17.                 _hierarchyWindow = _hierarchyWindow ?? GetWindowByName( "UnityEditor.SceneHierarchyWindow" );
    18.                 return ( _hierarchyWindow );
    19.             }
    20.         }
     
    jedy likes this.
  32. DLively

    DLively

    Joined:
    Sep 6, 2015
    Posts:
    33
    I downloaded your unity package, @Crazydadz
    Once I fixed it up to have no errors, I get more errors, and unity isn't functional... Seems interesting though.
     
  33. jedy

    jedy

    Joined:
    Aug 1, 2010
    Posts:
    578
    Guys - Tenebrous actually has the repository up on bitbucket to this day. He sporadically updates it to account for Unity updates, too.
     
  34. DLively

    DLively

    Joined:
    Sep 6, 2015
    Posts:
    33
    Thanks for the link, Jedy. Checking it out now.