Build could not find Unity.Animation.AnimationLocalToWorldOverride in a subscene

I encountered a fatal runtime error which led to failure to load a subscene containing some GameObjects with
component, DefaultAnimationGraphWriteTransformHandle:
“Cannot find TypeIndex for type hash 3625700120177732133. Ensure your runtime depends on all assemblies defining the Component types your data uses.”

The type hash 3625700120177732133 was referring to Unity.Animation.AnimationLocalToWorldOverride.

I once encountered the bug before this instance, I had solved the issue without making any changes in version control, and I was not sure what I had done solved it.

I could remove the DefaultAnimationGraphWriteTransformHandle component from all of the GameObjects to solve the issue, but I expected DefaultAnimationGraphWriteTransformHandle to work in runtime as well as Unity.Animation.AnimationLocalToWorldOverride

This error only happened during runtime on a standalone build, but the editor did not give any errors or warnings that might relate to the problem.

I am not sure what might be causing the problem. The best guess I could make is that it might be a bug within unity build system, and I am completely ignorant of it. I hope someone with some clues could help me out here(as well as some more unity users)

1 Like

Are you using Build Configuration (from Build Pipeline and with required target build platform package installed) instead of just good old Build button?

Yes, I am using the Build Configuration, and I have been following the instructions for standalone builds on the page: https://docs.unity3d.com/Packages/com.unity.entities@0.17/manual/install_setup.html?#standalone-builds

A quick sanity check:
:ballot_box_with_check: Installed com.unity.platforms.windows(I am using windows)
:ballot_box_with_check: Created a “Classic Build Configuration” asset
:ballot_box_with_check: Scene List contains the subscene and the “Build Current Scene” is checked
Additionally, I have two build configurations using il2cpp and mono as backend, the issue still occurs(the subscene would not load, program did not crash, error was threw)

1 Like

I’m a bit late to the party, but I stumbled across the same issue today.

Short answer :

add a link.xml anywhere under assets with the following content :

Long answer :

Unity is stripping away (seemingly) unused code when you build. The default setting when choosing Mono as backend is ‘Disabled’ (no stripping occurs). The default for IL2CPP is ‘Low’ (there is no ‘Disabled’ for IL2CPP).

Turns out that ITransformHandleComponents.cs gets stripped (which contains AnimationLocalToWorldOverride) as it seems to not be in use (can happen if it’s used by reflection for example).

The provided link.xml instructs the UnityLinker (which does the stripping at build time) to preserve everything inside the given namespace(s).

Notes :

  • It should be used sparingly with IL2CPP as it can increase build time tremendously as mentioned here :
    Unity - Manual: Managed code stripping
  • You can probably reduce the instructions in my provided link file to only preserve ITransformHandleComponents types instead of the entire assembly, I didn’t invest the time yet to find out all exact types that are getting stripped by accident.
1 Like