is it possible to extend Mecanim?

what i would like to so far:

color state nodes
color transitions by the color of state (switchable in/out maybe)

get all list of states and be able to work with them from custom inspector

is it possible to accomplish this somehow ?

(i know how to extend editor, i just don’t know if there is way to extend existing built in features like mecanim, animation timeline or connect to them from outside)

1 Answer

1

Pretty sure you’d have to rewrite the whole thing - which I guess wouldn’t actually be impossible - but quite an undertaking - to get that colouring.

You can get a list of all of the states from it using UnityEditorInternal and UnityEngineInternal then something like this:

List<Layer> layers;

class Layer
{
	public string name;
	public int index;
	public AnimatorControllerLayer layer;
	public HashSet<StateMachine> stateMachines;
	public List<State> states;
	public List<string> stateUniqueNames;
}

void WorkOutStates(AnimatorController controller)
{

	layers = Enumerable.Range(0, controller.layerCount).Select(c => {
		var layer = new Layer { layer = controller.GetLayer(c) };
		layer.name = layer.layer.name;
		layer.stateMachines = GetStateMachines(layer.layer.stateMachine);
		layer.states = layer.stateMachines.SelectMany(m=>Enumerable.Range(0, m.stateCount).Select(i=>m.GetState(i))).ToList();
		layer.stateUniqueNames = layer.states.Select(s=>s.uniqueName).ToList();
		return layer;
	}).ToList();

}

Oh yeah that's using System.Linq; too

I finally got it, now exploring the UnityEditorInternal, thank you very much

i finally got it; it works very well and it's very helpful, i'll make asset from this tool i made! thx very much mr. whydoidoit