Forum rules - please read before posting.

[Feature Request] Changing offsets and spacings of the "Remember" overlays in the Hierarchy tab

Hi there!

would be possible to add a preference setting to avoid this:

from happening?

I know I can hide them, but sometimes they just get in the way.
Being able to customise the icons out of the box would be a big plus.

For instance, for me it would be ok to change those overlays to coloured underlines. Gray for actionlists, and blue for a Remember component.

Comments

  • Having coloured underlines is a fair suggestion - but the advantage of having a dedicate "node" icon is that it provides a quick way of opening the ActionList.

    Oddly, I can't encounter an issue exactly like your screenshot - the node icons should be no more than 20 pixels away from the right edge of the window. I agree that they should be further to the right, but I think being able to customise their exact spacing is probably overkill - since the code to display them is small enough for it to just be copied and overridden completely.

    If you hide the icons via the bottom of the Settings Manager, you can bring them back up in the following Editor script:

    using UnityEditor;
    using UnityEngine;
    using System.Collections.Generic;
    
    namespace AC
    {
    
        [InitializeOnLoad]
        public class NewHierarchyIcons
        {
    
            private static List<int> actionListIDs;
            private static List<int> rememberIDs;
    
            private static ActionList[] actionLists;
            private static ConstantID[] constantIDs;
    
    
            static NewHierarchyIcons ()
            {
                EditorApplication.update += UpdateCB;
                EditorApplication.hierarchyWindowItemOnGUI += HierarchyItemCB;
            }
    
    
            private static void UpdateCB ()
            {
                actionLists = Object.FindObjectsOfType (typeof (ActionList)) as ActionList[];
    
                actionListIDs = new List<int>();
                foreach (ActionList actionList in actionLists)
                {
                    actionListIDs.Add (actionList.gameObject.GetInstanceID ());
                }
    
                constantIDs = Object.FindObjectsOfType (typeof (ConstantID)) as ConstantID[];
    
                rememberIDs = new List<int>();
                foreach (ConstantID constantID in constantIDs)
                {
                    rememberIDs.Add (constantID.gameObject.GetInstanceID());
                }
            }
    
    
            private static void HierarchyItemCB (int instanceID, Rect selectionRect)
            {
                // place the icon to the right of the list:
                Rect r = new Rect (selectionRect);
                r.x = r.width - 10;
                r.width = 18;
    
                if (actionListIDs != null && actionListIDs.Contains (instanceID))
                {
                    foreach (ActionList actionList in actionLists)
                    {
                        if (actionList != null && actionList.gameObject.GetInstanceID () == instanceID)
                        {
                            if (GUI.Button (r, string.Empty, CustomStyles.IconNodes))
                            {
                                ActionListEditorWindow.Init (actionList);
                                return;
                            }
                        }
                    }
                }
    
                r.x -= 25;
                if (rememberIDs != null && rememberIDs.Contains (instanceID))
                {
                    foreach (ConstantID constantID in constantIDs)
                    {
                        if (constantID != null && constantID.gameObject.GetInstanceID () == instanceID)
                        {
                            GUI.Label (r, string.Empty, CustomStyles.IconSave);
                            return;
                        }
                    }
                }
            }
    
        }
    
    }
    

    I've tweaked the values a little to make them more right-leaning.

  • You can also resize the Hierachy window to move them off the names.

  • I must have missed the email notification again :)

    Thanks for the snippet Chris!
    Peeking at it, that should cover most of my customisation needs :)

    With so many editor-enhancement assets around, I believe that having such issue could be way less than just a corner case scenario, since Scene-Tab enhancers usually draw their own overlays.

    So, sure, it's overkill if you just use AC alone in a project, I was merely suggesting that it could be more compatible with a few settings in the Preferences Window - so you don't clutter the interface more than needed. I think that would be a nice place where to put more advanced tweaking features.

    JackAnimated, I know, I may be a bit sleep-deprived, but not a newbie anymore. At least, not at the point of not knowing how to configure my working space :)

  • Here's a slightly tweaked version to remove a few "magic numbers"

    `using UnityEditor;
    using UnityEngine;
    using System.Collections.Generic;

    namespace AC
    {

    [InitializeOnLoad]
    public class NewHierarchyIcons
    {
        //public static float leftPadding = 7f;
        public static float rightPadding = -20f;
        public static float iconWidth = 16f;
        public static float iconSpacing = 7f;
    
        private static List<int> actionListIDs;
        private static List<int> rememberIDs;
    
        private static ActionList[] actionLists;
        private static ConstantID[] constantIDs;
    
    
        static NewHierarchyIcons ()
        {
            EditorApplication.update += UpdateCB;
            EditorApplication.hierarchyWindowItemOnGUI += HierarchyItemCB;
        }
    
    
        private static void UpdateCB ()
        {
            actionLists = Object.FindObjectsOfType (typeof (ActionList)) as ActionList[];
    
            actionListIDs = new List<int>();
            foreach (ActionList actionList in actionLists)
            {
                actionListIDs.Add (actionList.gameObject.GetInstanceID ());
            }
    
            constantIDs = Object.FindObjectsOfType (typeof (ConstantID)) as ConstantID[];
    
            rememberIDs = new List<int>();
            foreach (ConstantID constantID in constantIDs)
            {
                rememberIDs.Add (constantID.gameObject.GetInstanceID());
            }
        }
    
    
        private static void HierarchyItemCB (int instanceID, Rect selectionRect)
        {
            // place the icon to the right of the list:
            Rect r = new Rect (selectionRect);
            r.x = r.width - rightPadding; //leftPadding;
            r.width = iconWidth;
    
            if (actionListIDs != null && actionListIDs.Contains (instanceID))
            {
                foreach (ActionList actionList in actionLists)
                {
                    if (actionList != null && actionList.gameObject.GetInstanceID () == instanceID)
                    {
                        if (GUI.Button (r, string.Empty, CustomStyles.IconNodes))
                        {
                            ActionListEditorWindow.Init (actionList);
                            return;
                        }
                    }
                }
            }
    
            r.x -= iconWidth + iconSpacing; //+= iconWidth + iconSpacing; 
            if (rememberIDs != null && rememberIDs.Contains (instanceID))
            {
                foreach (ConstantID constantID in constantIDs)
                {
                    if (constantID != null && constantID.gameObject.GetInstanceID () == instanceID)
                    {
                        GUI.Label (r, string.Empty, CustomStyles.IconSave);
                        return;
                    }
                }
            }
        }
    }
    

    }`

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.