Indent or resize entire components in custom inspector


Now I’m not sure if this is even possible, after what feels like a ton of googling I can’t come up with any answers so I’m asking the question here instead. I have made a component-based hierarchial state-machine in unity and got it to work pretty well. Unfortunately I do have the knowledge for how to make a node-based Editor in Unity and can’t really find any tutorials that are free and looks good so I have for now settled with having the ftm in the inspector.

The problem I am trying to solve right now is if it is possible to indent entire components, each state in my state machine is a component, and what I would like to to do in my custom inspector is to indent each state that is a substate to another, thereby creating a nice hiearchy where you can clearly see state and substates in the editor. Although I’m not finding any way to actually controll the component widht, height or even indention level. So I am wondering if this is even possible, if it is not, does anyone at least know a way to get the position of an component in the inspector so I can insert color-based rects to tell which state belong to eachother.

Grateful for any answers, and I apologise for the tl;dr.


EDIT: Here’s a image of kind of what I am looking for, sorry if I confused anyone.


Should do the trick if you are using GUILayout. :slight_smile:


If you are doing a recursion, then I might suggest something like this.

    void IterateStates(State state)
        if (state.States != null)
            foreach (State enemyState in state.States )
                if (enemyState != null)
                    GUILayout.Space(15 * stateHierarchy);
                    EditorGUILayout.ObjectField(enemyState, typeof(State), false);
                    IterateStates(enemyState );