Search Unity

Utilities PrettyHierarchy - Color hierarchy objects

Discussion in 'Tools In Progress' started by ADNCG, Nov 7, 2020.

  1. ADNCG

    ADNCG

    Joined:
    Jun 9, 2014
    Posts:
    994
    PrettyHierarchy allows you to assign colors to your hierarchy objects.

    To use, simply add a PrettyObject component to any of your GameObjects.

    Note : I designed it to match the hierarchy post-2019.3. You'll most likely get visual artifacts if you try to use it with an earlier version.

    https://github.com/NCEEGEE/PrettyHierarchy/tree/main

    I hope you'll find it as useful as I do :)


    Hierarchy

    hierarchy-preview.png


    Component

    component-preview.png
     
    Last edited: Jan 16, 2023
    StickMoon, epicdo, Blenderik and 11 others like this.
  2. sameng

    sameng

    Joined:
    Oct 1, 2014
    Posts:
    184
    Very cool, just started using it. I added a toggle for Background Color, which greatly improved my experience.

    Thanks for making it and sharing!
     
    ADNCG likes this.
  3. Goty-Metal

    Goty-Metal

    Joined:
    Apr 4, 2020
    Posts:
    168
    Works like a charm, hope it gets up to date for long time :)
     
    ADNCG likes this.
  4. Goty-Metal

    Goty-Metal

    Joined:
    Apr 4, 2020
    Posts:
    168
    Sorry man just updated to 2020.3.2f1 and stopped working :confused:... good job anyway!

    Assets\PrettyHierarchy\Utils\EditorUtils.cs(7,62): error CS0103: The name 'EditorWindow' does not exist in the current context
    Assets\PrettyHierarchy\Utils\EditorUtils.cs(7,100): error CS0103: The name 'EditorWindow' does not exist in the current context
    Assets\PrettyHierarchy\Utils\EditorColors.cs(32,57): error CS0103: The name 'EditorGUIUtility' does not exist in the current context
    Assets\PrettyHierarchy\Utils\EditorColors.cs(36,71): error CS0103: The name 'EditorGUIUtility' does not exist in the current context
    Assets\PrettyHierarchy\Utils\EditorColors.cs(40,84): error CS0103: The name 'EditorGUIUtility' does not exist in the current context
    Assets\PrettyHierarchy\Utils\EditorColors.cs(44,59): error CS0103: The name 'EditorGUIUtility' does not exist in the current context
    Assets\PrettyHierarchy\Utils\EditorColors.cs(50,51): error CS0103: The name 'EditorGUIUtility' does not exist in the current context
    Assets\PrettyHierarchy\Utils\EditorColors.cs(54,65): error CS0103: The name 'EditorGUIUtility' does not exist in the current context
    Assets\PrettyHierarchy\Utils\EditorColors.cs(58,78): error CS0103: The name 'EditorGUIUtility' does not exist in the current context
    Assets\PrettyHierarchy\Runtime\PrettyObject.cs(36,13): error CS0103: The name 'EditorApplication' does not exist in the current context
    ...
     
  5. ADNCG

    ADNCG

    Joined:
    Jun 9, 2014
    Posts:
    994
    Hey, thank you for letting me know! I'll investigate...
     
    Goty-Metal likes this.
  6. ADNCG

    ADNCG

    Joined:
    Jun 9, 2014
    Posts:
    994
    I have not been able to reproduce your issue. Installed 2020.3.2f1 and it works out of the box. It might be something specific to your project.
     
    Goty-Metal likes this.
  7. Goty-Metal

    Goty-Metal

    Joined:
    Apr 4, 2020
    Posts:
    168
    Weird! i just updated Unity and nothing more, i'll try again, do i have to put it in any "special" folder?

    Now if i import it into the project i get this warning:
    There are inconsistent line endings in the 'Assets/PrettyHierarchy/Runtime/PrettyObject.cs' script. Some are Mac OS X (UNIX) and some are Windows.
    This might lead to incorrect line numbers in stacktraces and compiler errors. Many text editors can fix this using Convert Line Endings menu commands.
    UnityEngine.GUIUtility:processEvent (int,intptr,bool&)

    I'm using windows.
     
  8. ADNCG

    ADNCG

    Joined:
    Jun 9, 2014
    Posts:
    994
    Putting it directly in your assets folder is fine
    That warning should be safe to ignore, I'll get around to fixing that.

    Is the warning all you get? Errors are gone?
     
  9. Goty-Metal

    Goty-Metal

    Joined:
    Apr 4, 2020
    Posts:
    168
    Ok so the error ONLY happens when i try to build the game, not in editor mode, i tried to put ALL scripts in the EDITOR folder and that makes the compilation error dissapears but then the component PrettyObject is gone.. so basically...
    A. If i just import the project in assets "PrettyHierarchy" folder with subfolders etc i can't build the game because i get those errors.
    B. If i take all scrips out of their folders and i put them all together in the Editor folder i can build the game but i can't use the PrettyObject component because Unity cannot find it.

    So i'm on a deadend :/
     
    ADNCG likes this.
  10. ADNCG

    ADNCG

    Joined:
    Jun 9, 2014
    Posts:
    994
    Yeah, that's on me. Thank you for raising this issue!

    If you want to use it before I release the fix, reorganize the folders by dragging the "Utils" folder into the "Editor" folder and then edit the "PrettyObject" script by replacing this :
    Code (CSharp):
    1. private void OnValidate()
    2. {
    3.     EditorApplication.RepaintHierarchyWindow();
    4. }
    with this :
    Code (CSharp):
    1. #if UNITY_EDITOR
    2.         private void OnValidate()
    3.         {
    4.             EditorApplication.RepaintHierarchyWindow();
    5.         }
    6. #endif
    Alternatively, if you rather wait, I'll get around to fixing this and I'll update this thread when I do
     
    Goty-Metal likes this.
  11. Goty-Metal

    Goty-Metal

    Joined:
    Apr 4, 2020
    Posts:
    168
    Sure pal, i'll wait, i'm really grateful, thanks for the great utility and support :), you should upload it to the asset store!
     
    EpicMcDude and ADNCG like this.
  12. tobiasvanelk

    tobiasvanelk

    Joined:
    Apr 7, 2020
    Posts:
    5
    This is such a great, simple utility! Thank you so much for sharing!
     
    ADNCG and Goty-Metal like this.
  13. ARRAYEWHY

    ARRAYEWHY

    Joined:
    Jan 9, 2014
    Posts:
    9
    This is wonderful! Thank you so much!
     
    ADNCG likes this.
  14. Arsenikstiger

    Arsenikstiger

    Joined:
    Dec 17, 2020
    Posts:
    3
    Thank you very much, very useful !
     
    ADNCG likes this.
  15. ADNCG

    ADNCG

    Joined:
    Jun 9, 2014
    Posts:
    994
    Glad you like it :) Thank you!
     
  16. reij

    reij

    Joined:
    Oct 14, 2018
    Posts:
    17
    Thanks bro, looks cool, was looking for something like this for a while <3
     
  17. ADNCG

    ADNCG

    Joined:
    Jun 9, 2014
    Posts:
    994
    Thank you! I appreciate the kind words :)
     
    reij likes this.
  18. VHMoschini

    VHMoschini

    Joined:
    Apr 26, 2019
    Posts:
    1
    Thank's Bro! :D It help me a lot, working on a organized project make all the difference!
     
  19. ADNCG

    ADNCG

    Joined:
    Jun 9, 2014
    Posts:
    994
    Thank you, I appreciate it :)
     
  20. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    429
    So glad I came across this. I've a number of paid assets that kind of do this but are so much more bloated. Thanks for sharing.

    I've a suggestion which I've added as an issue on github:
    Request for faded color when Hierarchy Object is disabled
    Once PrettyObject is added, there is no longer a visual cue as to that object's Active state. (Default editor colors fade out the name to designate disabled objects)

    Would be awesome if this could be added! Thanks.
     
    ADNCG likes this.
  21. ADNCG

    ADNCG

    Joined:
    Jun 9, 2014
    Posts:
    994
    Thank you for letting me know. Updated with fix.

    Small issue, multi editing is now disabled. I'll upload a fix soon as I can.
     
    havokentity and jeromeWork like this.
  22. ADNCG

    ADNCG

    Joined:
    Jun 9, 2014
    Posts:
    994
    All fixed!
     
    havokentity likes this.
  23. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    429
    Thanks :) Works great.

    And moving that Utility folder into an Editor folder doesn't break Builds either.

    Working great now.
     
    havokentity and ADNCG like this.
  24. puppetnonsense

    puppetnonsense

    Joined:
    Nov 15, 2014
    Posts:
    2
    Can't seem to get it to work. I just drag the whole folder into the asset folder yea? (Unity 2020.3)
     
  25. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    429
    And then add the PrettyObject script onto whichever GameObject you want highlighted in the Hierarchy. Pick your colour in the component's Inspector.
     
    havokentity and ADNCG like this.
  26. wedgiebee

    wedgiebee

    Joined:
    Aug 9, 2016
    Posts:
    40
    Hi there @ADNCG , is it correct that when I select a pretty object in the hierarchy, it's background color disappears? Or do I have something set up wrong? Mine is set to red, but when I click it in the hierarchy it disappears while it's active.

    not selected:
    Screen Shot 2022-06-15 at 3.38.49 PM.png

    selected:
    Screen Shot 2022-06-15 at 3.38.42 PM.png

    (sorry idk why the images are so small but they should get bigger if you click them!)
     
  27. ADNCG

    ADNCG

    Joined:
    Jun 9, 2014
    Posts:
    994
    It's been a bit since I've touched this but iirc that was by design to be consistent with unity's different selection states.

    You can modify that by opening up the PrettyHierarchy.cs script and modifying the PaintBackground method.

    For instance, if you replace it with this one, it'll give you the middle color between your custom color and the default selected background color for your current unity theme
    Code (CSharp):
    1.  
    2. private static void PaintBackground(HierarchyItem item)
    3. {
    4.     Color32 color = item.PrettyObject.UseDefaultBackgroundColor ? EditorColors.GetDefaultBackgroundColor(EditorUtils.IsHierarchyFocused, item.IsSelected) : item.PrettyObject.BackgroundColor;
    5.  
    6.     if (item.IsSelected)
    7.     {
    8.         color = Color.Lerp(EditorColors.GetDefaultBackgroundColor(EditorUtils.IsHierarchyFocused, item.IsSelected), color, 0.5f);
    9.     }
    10.  
    11.     EditorGUI.DrawRect(item.BackgroundRect, color);
    12. }
     
    Last edited: Jun 16, 2022
    wedgiebee likes this.
  28. wedgiebee

    wedgiebee

    Joined:
    Aug 9, 2016
    Posts:
    40
    Ahhhhhh that's perfect, thanks so much! I've been messing around and enjoying how pretty my hierarchy is now, great asset!
     

    Attached Files:

    zxcvb497333 and ADNCG like this.
  29. Proto-G

    Proto-G

    Joined:
    Nov 22, 2014
    Posts:
    213
    So awesome for organizing my projects! Thanks
     
    ADNCG likes this.
  30. skudgee

    skudgee

    Joined:
    Jun 17, 2015
    Posts:
    5
    Awesome !
    Works on 2021 dark theme, thanks !!!
     
    ADNCG likes this.
  31. Beldir

    Beldir

    Joined:
    Feb 27, 2015
    Posts:
    1
    Works great. Doesn't looks like it's updated anymore but any chance we'll get an "apply to children" toggle?^^