Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Rainbow Hierarchy - highlighting often used objects in your scene

Discussion in 'Assets and Asset Store' started by PhannGor, Jan 22, 2018.

  1. PhannGor

    PhannGor

    Joined:
    Feb 5, 2015
    Posts:
    226
    Hi @Antonidiuss,

    Do you use the latest version of the Rainbow Hierarchy? Could you please provide more info regarding that issue? Is that issue happening only for one project? Only for a particular scene? Do you able to reproduce it on a clean project without any other assets?

    I've just done another performance test with more than 100 000 GOs in a scene, and more than 4000 different rules applied to them. So far I don't see any significant performance degradation. Would appreciate it if you could help with clear steps/conditions to reproduce this issue.
     
  2. Pourya-MDP

    Pourya-MDP

    Joined:
    May 18, 2017
    Posts:
    143
    hi there @PhannGor first of all thanks for this amazing plugin
    im trying to create gameobjects using contex menu and at the same time add rainbow effects to them , however i cant find any method or API for doing rainbowy things using script, can you please provide a example scene or maybe a piece of code to get started with?
    i already tried to import source packages to see if im missing something from that package but after importing i have many errors in my console
    im using unity 2020.2 and rainbow hierarchy latest version
    2022.04.24_01.png
    thanks in advance
     
  3. PhannGor

    PhannGor

    Joined:
    Feb 5, 2015
    Posts:
    226
    Hi @Pourya-MDP,

    Regarding the source package:
    • You need to remove the DLL assembly under
      Code (CSharp):
      1. ../RainbowHierarchy/Assemblies/
      folder because if you've imported source scripts, they will conflict with the same script from DLL.

    • Then you need manually assign the RainbowHierarchyRuleset.cs (or RainbowHierarchyRulesetV2.cs in latest version) to your ruleset object in the active scene. Unity handles GUIDs for scripts differently for source and DLLs, that's the reason.

    upload_2022-4-24_11-2-26.png
     
    Pourya-MDP likes this.
  4. PhannGor

    PhannGor

    Joined:
    Feb 5, 2015
    Posts:
    226
    @Pourya-MDP,

    Regarding your initial question, here is the example how it is possible to assign icons from script:

    Code (CSharp):
    1. using System.Linq;
    2. using Borodar.RainbowHierarchy;
    3. using UnityEditor;
    4.  
    5. namespace Borodar.Support
    6. {
    7.     public static class AssignIconFromMenu
    8.     {
    9.         [MenuItem("Rainbow Hierarchy/Assign Icon to Selected Objects")]
    10.         private static void AssignIconToSelectedObjects()
    11.         {
    12.             var selectedObjects = Selection.gameObjects.ToList();
    13.  
    14.             var currentScene = selectedObjects.First().scene;
    15.             var ruleset = HierarchyRulesetV2.GetRulesetByScene(currentScene, true);
    16.  
    17.             foreach (var selectedObject in selectedObjects)
    18.             {
    19.                 // objects can be selected across multiple scenes
    20.                 if (currentScene != selectedObject.scene)
    21.                 {
    22.                     currentScene = selectedObject.scene;
    23.                     ruleset = HierarchyRulesetV2.GetRulesetByScene(currentScene, true);
    24.                 }
    25.  
    26.                 var rule =
    27.                     ruleset.GetRule(selectedObject) ??
    28.                     new HierarchyRule(HierarchyRule.KeyType.Object, selectedObject, string.Empty);
    29.  
    30.                 rule.GameObject = rule.Type == HierarchyRule.KeyType.Name ? null : selectedObject;
    31.                 rule.Name = rule.Type == HierarchyRule.KeyType.Name ? selectedObject.name : null;
    32.  
    33.                 rule.IconType = HierarchyIcon.CollabChanges;
    34.                 rule.BackgroundType = HierarchyBackground.ClrSkyBlue;
    35.  
    36.                 Undo.RecordObject(ruleset, "Rainbow Hierarchy Ruleset Changes");
    37.                 ruleset.UpdateRule(selectedObject, rule);
    38.             }
    39.  
    40.         }
    41.     }
    42. }
    You can invoke it from main menu:

    upload_2022-4-24_11-37-25.png
     
    Pourya-MDP likes this.
  5. Pourya-MDP

    Pourya-MDP

    Joined:
    May 18, 2017
    Posts:
    143
    nice!
    so much thanks for the help
    also errors gone with mentioned workaround
     
  6. Pourya-MDP

    Pourya-MDP

    Joined:
    May 18, 2017
    Posts:
    143
    hey again @PhannGor i have a error in my script when i try to use older versions of rainbow hierarchy (because my project is in 2019.4 and i have to use rainbow hierarchy 2.4 or 2.5) it seems that there is no such method in older versions , so how to set background in older versions? 2022.04.24_12.png
     
  7. PhannGor

    PhannGor

    Joined:
    Feb 5, 2015
    Posts:
    226
    Class is probably named differently. I don't remember the exact name and far from my desk now. Should be something like CoreBackground. Your IDE should propose to autocomplete option. Or you could take a look which type the rule.BackgroundType field should accept.

    If not, then I'll take a look tomorrow and will let you know.
     
  8. Pourya-MDP

    Pourya-MDP

    Joined:
    May 18, 2017
    Posts:
    143
    i already wanted to mess with it but no chance at all
    i will appreciate if you can name the property when you get behind your machine
    looking forward to it
    thanks in advance
     
  9. PhannGor

    PhannGor

    Joined:
    Feb 5, 2015
    Posts:
    226
    Here is modified script for older version:

    Code (CSharp):
    1. using System.Linq;
    2. using Borodar.RainbowCore;
    3. using Borodar.RainbowHierarchy;
    4. using UnityEditor;
    5.  
    6. namespace Borodar.Support
    7. {
    8.     public static class AssignIconFromMenu
    9.     {
    10.         [MenuItem("Rainbow Hierarchy/Assign Icon to Selected Objects")]
    11.         private static void AssignIconToSelectedObjects()
    12.         {
    13.             var selectedObjects = Selection.gameObjects.ToList();
    14.  
    15.             var currentScene = selectedObjects.First().scene;
    16.             var ruleset = HierarchyRuleset.GetRulesByScene(currentScene, true);
    17.  
    18.             foreach (var selectedObject in selectedObjects)
    19.             {
    20.                 // objects can be selected across multiple scenes
    21.                 if (currentScene != selectedObject.scene)
    22.                 {
    23.                     currentScene = selectedObject.scene;
    24.                     ruleset = HierarchyRuleset.GetRulesByScene(currentScene, true);
    25.                 }
    26.  
    27.                 var rule =
    28.                     ruleset.GetRule(selectedObject) ??
    29.                     new HierarchyRule(HierarchyRule.KeyType.Object, selectedObject, string.Empty);
    30.  
    31.                 rule.GameObject = rule.Type == HierarchyRule.KeyType.Name ? null : selectedObject;
    32.                 rule.Name = rule.Type == HierarchyRule.KeyType.Name ? selectedObject.name : null;
    33.  
    34.                 rule.IconType = HierarchyIcon.ClrBlue;
    35.                 rule.BackgroundType = CoreBackground.ClrBlue;
    36.  
    37.                 Undo.RecordObject(ruleset, "Rainbow Hierarchy Ruleset Changes");
    38.                 ruleset.UpdateRule(selectedObject, rule);
    39.             }
    40.  
    41.         }
    42.     }
    43. }
     
    Pourya-MDP likes this.
  10. rrahim

    rrahim

    Joined:
    Nov 30, 2015
    Posts:
    206
    Hi, is there any way to get access to all of the icons in an image format, so that I can edit them for my custom needs?
     
  11. ThatRaincoat

    ThatRaincoat

    Joined:
    Jul 12, 2017
    Posts:
    27
    Is there a way to add a rule for components? Curious about making it so all game objects with a Light component show a light bulb icon.
     
  12. PhannGor

    PhannGor

    Joined:
    Feb 5, 2015
    Posts:
    226
    Unfortunately, there is no way to add rules depending on the components attached to a game object.
     
  13. PhannGor

    PhannGor

    Joined:
    Feb 5, 2015
    Posts:
    226
    All textures are encoded into Base64 strings. You could use something like that to convert them to PNG:

    Code (CSharp):
    1.  
    2. using System;
    3. using System.Diagnostics.CodeAnalysis;
    4. using System.IO;
    5. using UnityEditor;
    6. using UnityEngine;
    7.  
    8. public class StringToTextureWindow : EditorWindow
    9. {
    10.     private string _stringValue;
    11.  
    12.     [MenuItem("Tools/Borodar/String To Texture")]
    13.     public static void ShowWindow()
    14.     {
    15.         GetWindow<StringToTextureWindow>().Show();
    16.     }
    17.  
    18.     private void OnGUI()
    19.     {
    20.         EditorGUILayout.Space();
    21.         _stringValue = EditorGUILayout.TextField("Encoded", _stringValue);
    22.         EditorGUILayout.Space();
    23.  
    24.         if (GUILayout.Button("Convert") && !string.IsNullOrEmpty(_stringValue))
    25.         {
    26.             var texture = TextureFromString(_stringValue, FilterMode.Point);
    27.             var pngBytes = texture.EncodeToPNG();
    28.             File.WriteAllBytes(Application.dataPath + "/../Build/icon_from_tex.png", pngBytes);
    29.         }
    30.  
    31.         if (GUILayout.Button("Clear"))
    32.         {
    33.             _stringValue = null;
    34.         }
    35.     }
    36.  
    37.     [SuppressMessage("ReSharper", "UseObjectOrCollectionInitializer")]
    38.     private static Texture2D TextureFromString(string value, FilterMode filterMode)
    39.     {
    40.         var texture = new Texture2D(0, 0, TextureFormat.ARGB32, false, false);
    41.         texture.filterMode = filterMode;
    42.         texture.wrapMode = TextureWrapMode.Clamp;
    43.         texture.hideFlags = HideFlags.HideAndDontSave;
    44.         texture.LoadImage(Convert.FromBase64String(value));
    45.         return texture;
    46.     }
    47. }
    48.  
     
    Stexe and rrahim like this.
  14. rrahim

    rrahim

    Joined:
    Nov 30, 2015
    Posts:
    206
    Awesome, thanks.
    I was manually converting them as needed, didn't think to use a script.
     
  15. Urganot

    Urganot

    Joined:
    Dec 10, 2012
    Posts:
    9
    Is there a default ruleset like for rainbow folders?
    Also is it possible to use a wildcard? for example I want all my hierarchy objects with camera in their name to have the camera symbol. currently I can only add "camera" as a name and this wont find "main camera" something like "*camera*" maybe
     
  16. PhannGor

    PhannGor

    Joined:
    Feb 5, 2015
    Posts:
    226
    No, there is no default ruleset for Rainbow Hierarchy because it works differently and those rules are applied per scene. As a workaround, You could use the import/export tool to easily apply one ruleset to different scenes
     
  17. danielesuppo

    danielesuppo

    Joined:
    Oct 20, 2015
    Posts:
    331
    Hi,
    BUG - in Unity 2022.x when you change an icon the upper one flash
     
  18. PythagoRascal

    PythagoRascal

    Joined:
    Oct 25, 2012
    Posts:
    26
    Hi!

    I just recently bought RainbowHierarchy and it is looking good so far. Though, I was wondering if you are still updating this asset?

    I would especially appreciate the option of a project-wide ruleset like in RainbowFolders (maybe with the option to override with per scene rulesets) and the option for Regex matching the object names.

    Is this something you'd be willing to add?

    In any case, thank you for the asset!
     
  19. PhannGor

    PhannGor

    Joined:
    Feb 5, 2015
    Posts:
    226
    Hi @PythagoRascal,

    Yes, we're still supporting and updating it. However, have a bit less time for that because of russian invasion and full-scale war in our country as a result of that...

    Anyway, your proposal about a project-wide ruleset is awesome. I've been thinking for a long time regarding that feature as well. I'm definitely more than willing to implement it but there are technical limitations, like object references between scenes, etc.

    Probably, I'll introduce a kind of regex matching first and will make only those rules to be "project-wide" because that doesn't require object referencing at all. I'm planning the next "compatibility" update to be available in July anyway and will do my best to include at least some of those features as well.

    Thank you for the purchase and the feedback!
     
  20. PythagoRascal

    PythagoRascal

    Joined:
    Oct 25, 2012
    Posts:
    26
    @PhannGor amazing! Thank you for the response, I'll happily wait for those features and I agree that regex-matching is probably a good place to start.

    Also, I'm sorry to hear that you are so directly affected by the war. All the best and much strength to you and yours!
     
    PhannGor likes this.
  21. NecroToad

    NecroToad

    Joined:
    Oct 27, 2014
    Posts:
    8
    Hey @PhannGor, first off, let me just say how much I admire Rainbow Hierarchy. It's been a game-changer in organizing complex scenes – can't thank you enough for such a phenomenal asset!

    I've recently updated my project to 2023.1.6f1 and I've run into some issues with Rainbow Hierarchy. I'm getting a bunch of error messages and my hierarchy has gone blank.

    I realize you're dealing with a lot right now, so I completely understand if you're tied up. But if you happen to have a moment to take a look at this, I'd be incredibly grateful. Thanks so much, and keep up the fantastic work!
     

    Attached Files:

    • Bug.png
      Bug.png
      File size:
      286.2 KB
      Views:
      24
    PhannGor likes this.
  22. PhannGor

    PhannGor

    Joined:
    Feb 5, 2015
    Posts:
    226
    Hi @NecroToad,

    Thanks for reporting this! And for your warm words as well. Will take a look, seems similar to the compatibility issue that our RF2 had with Unity 2023.1+. Will take a look and prepare the fix ASAP.
     
    NecroToad likes this.
  23. NecroToad

    NecroToad

    Joined:
    Oct 27, 2014
    Posts:
    8
    Thank you so much for your quick response! I really appreciate you taking the time to look into this issue, I'm looking forward to the fix whenever you manage to get around to it. Take care and keep up the great work!
     
    PhannGor likes this.
  24. PhannGor

    PhannGor

    Joined:
    Feb 5, 2015
    Posts:
    226
    Fixed and uploaded to the Asset Store. Should be publicly available after their review which could take a few working days.
     
  25. NecroToad

    NecroToad

    Joined:
    Oct 27, 2014
    Posts:
    8
    That was super fast, thank you! I just noticed the update has already gone live and had a chance to test it. Everything is back to normal now, working perfectly.

    Really appreciate your quick action on this. Thanks again!