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

Animator.parameters array empty when in prefab

Discussion in 'Animation' started by LazloBonin, Jun 21, 2015.

  1. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    809
    I'm trying to access the Animator.parameters array from a custom inspector.

    It works perfectly when the GameObject is placed in the scene view.
    However, when it's a accessed as a prefab (from the project pane), the array is empty.

    Is this a bug, or is there some way to access the parameters?
     
  2. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Yes this is expected, when an animator is not loaded all the internal memory is not created.

    In fact parameters are create on the AnimatorController so if you want to know which parameter exist on the asset you should use
    http://docs.unity3d.com/ScriptReference/Animations.AnimatorController-parameters.html

    Keep in mind that the animator is the runtime component for evaluation and the controller is the assset, so when the game is not running the controller asset is not yet instanciated.
     
    LazloBonin likes this.
  3. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    809
    Thanks! Is there a way to get the underlying AnimatorController from the Animator class?
     
  4. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Rodolfo-Rubens and theANMATOR2b like this.
  5. gattusoarthur

    gattusoarthur

    Joined:
    Apr 29, 2020
    Posts:
    5