Question about serialization of AnimatorController assets and their sub-assets

Aloha! :palm_tree:

I have a question concerning the serialization of AnimatorController assets, specifically the sub-assets they contain.

Question:

Is it safe to manually remove sub-assets from the serialized data of an AnimatorController asset, when those sub-assets don’t seem to be referenced by anything else in the AnimatorController ?

Context:

In my AnimatorController, I have been tweaking settings, like state settings and state transition settings.
For version control (git), I was reviewing the changes I made. When doing so, I am of course viewing the serialized data from the file.
However, I found it difficult to do so when the connection between, for example, a transition and the state it belongs to, is via a guid. The transition isn’t serialized immediately after the state, but can exist at any random point in the serialized data. This made it hard for me to know which specific transition I was reviewing.

I then noticed that it’s possible to add a name to transitions. By default, the transitions in the AnimatorController are displayed with the name “[origin state] → [destination state]”, but this display name is not actually serialized in the data.
So, I scripted a tool that would loop over all transitions in the AnimatorController and assign a name to them. This way, the serialized representation of the transition would have the name be easily identifiable.

After running this tool, a lot of names appeared in the serialized data - as expected.
However, I noticed some transitions in the serialized file remained without name. Odd, I thought.
I then searched the file for the guid of those nameless transitions, and discovered they weren’t referenced by anything.
From what I understand, the AnimatorController asset contains sub-assets of all the things in the AnimatorController (state machines, states, transitions). It seems these unreferenced transitions are sub-assets in the AnimatorController, but are not referenced by anything else in the AnimatorController, i.e. no state or statemachine is using these transitions.

It then seems there is no functionality in Unity to clean these unreferenced sub-assets. I’m not sure how they have come to be, as removing a transition in the editor also removes its serialized data normally.

Anyways, all I want to know now is whether I can safely remove any transition sub-asset from the serialized data, when they are not referenced by anything else in the serialized data.

Thanks in advance :slight_smile: