Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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

Discussion in 'Entity Component System' started by IgreygooI, Mar 28, 2021.

  1. IgreygooI

    IgreygooI

    Joined:
    Mar 13, 2021
    Posts:
    48
    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)
     
    Arnold_2013 likes this.
  2. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,683
    Are you using Build Configuration (from Build Pipeline and with required target build platform package installed) instead of just good old Build button?
     
  3. IgreygooI

    IgreygooI

    Joined:
    Mar 13, 2021
    Posts:
    48
    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/c.../manual/install_setup.html?#standalone-builds

    A quick sanity check:
    ☑ Installed com.unity.platforms.windows(I am using windows)
    ☑ Created a "Classic Build Configuration" asset
    ☑ 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)
     
    Tony_Max likes this.
  4. MarcelArioli

    MarcelArioli

    Joined:
    May 31, 2014
    Posts:
    28
    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 :

    <linker>
    <!--Preserve entire assembly-->
    <assembly fullname="Unity.Animation.DefaultGraphPipeline.Hybrid" preserve="all"/>
    <assembly fullname="Unity.Animation" preserve="all"/>
    </linker>

    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 :
    https://docs.unity3d.com/Manual/ManagedCodeStripping.html
    - 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.
     
    Arnold_2013 likes this.