Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Animator can store not used reference (warnings at console)

Discussion in 'Animation' started by DSivtsov, Aug 8, 2023.

  1. DSivtsov

    DSivtsov

    Joined:
    Feb 20, 2019
    Posts:
    150
    Animator can contains not used references to early deleted StateMachineBehaviour scripts.
    You can't detect this in Editor (it doesn't check this). All will work in Editor right and not give any messages.

    But if you use Zenject and Git (or other version control system) and decided to transfer your project to other computer.

    You can met with next issue:
    On first run your project on new system you can get next warnings messages:
    (See Log.txt)
    The Zenject for every GameObject with Animator will try to call
    ZenjectStateMachineBehaviourAutoInjecter
    and this ultimately generate these messages.
    If you not use Zenject for Injection based on this script all other will work right (I didn't find another effect).
    It's not big problem, but not nice.

    You can find these garbage reference, by any text Editor in your Animator file, searching or corespondent states (fields "m_Name: <StateName>") or reference to "StateMachineBehaviour scripts" (fields "m_StateMachineBehaviours:").
    In my file I found e.g. like that
    Code (CSharp):
    1.   m_StateMachineBehaviours:
    2.   - {fileID: -1220918271486965890}
    The Animator contains block with
    fileID: -1220918271486965890
    , but this record have a link to "wrong guid" (guid of absent file)
    The right values (in format of Unity 2021.3.7)
    Code (CSharp):
    1. m_StateMachineBehaviours: []
     

    Attached Files:

    • Log.txt
      File size:
      53.9 KB
      Views:
      39
  2. DSivtsov

    DSivtsov

    Joined:
    Feb 20, 2019
    Posts:
    150
    I didn't know why this issue occur only at transfer repo (on original machine all works without any warnings).
    Workaround to resolve this issue:
    • On cloned project sometimes work simply open the animator and open (by click) all problematic states (one by one). It didn't set right values, but something changing and after that project will start without any warning (as on original computer). :)It's some old powerful Magic of Editor.
    • More appropriate variant (IMHO) it's to initiated rewriting Animator file. I did it by add (and after remove) some temporary "StateMachineBehaviour scripts". In this case the Editor set right values in "m_StateMachineBehaviours: []" fields.
      (but Animator will continue to store blocks of records with link to "wrong guid", but this will not affect on work of your project)
     
    Last edited: Aug 8, 2023
  3. SolarianZ

    SolarianZ

    Joined:
    Jun 13, 2017
    Posts:
    215
    If I remember correctly, if you create a duplicate of an AnimatorController using Ctrl+D and proceed to modify the AnimationClip within the State of the duplicated AnimatorController, the AnimatorController will still retain a reference to the original AnimationClip, even if it is not visible.