Search Unity

After saving the scene: Animator is not playing an AnimatorController

Discussion in 'Animation' started by Zwer99, May 23, 2018.

  1. Zwer99

    Zwer99

    Joined:
    Oct 24, 2013
    Posts:
    24
    Hello!

    I've written an editor-script which reads the parameters of the Animator. I'm also doing some null-checks and it works fine:

    Code (CSharp):
    1. if (animator != null && animator.gameObject.activeSelf && animator.runtimeAnimatorController != null)
    2.     parameters = animator.parameters;
    But after saving the scene I'm getting the following error:

    Code (CSharp):
    1. Animator is not playing an AnimatorController
    2. UnityEngine.Animator:get_parameters()
    The program passes the null-checks, but says that there's no AnimatorController playing in line 2 of the snipped above. The only way to make it work again is to remove the AnimatorController in the inspector and reassign it. What can I do? Why is that only after saving the scene?

    Thank you very much :)
     
    Last edited: May 23, 2018
  2. Zwer99

    Zwer99

    Joined:
    Oct 24, 2013
    Posts:
    24
    No ideas?
     
  3. Zwer99

    Zwer99

    Joined:
    Oct 24, 2013
    Posts:
    24
    Really no ideas ^^?
    Sorry for pushing, but I need to fix this.
    Either this is a bug or I need to check against another condition?

    Thanks :)
     
  4. Veetha

    Veetha

    Joined:
    Jun 27, 2017
    Posts:
    3
    Did you find a solution? I've ran into same problem... :(
     
  5. Veetha

    Veetha

    Joined:
    Jun 27, 2017
    Posts:
    3
    For anyone who have ran into similar problem and known solutions didn't work for him. You can work-around by turning animation controller off and on like this:

    Code (CSharp):
    1. if (GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).length == 0 )
    2.         {        
    3.             print("Warning: animation state info length = 0, restarting animator...");
    4.  
    5.             /* workaround for recurring error message "Animator is not playing an AnimatorController" which emerged after every save of project and prevented further operating the script until animation controller weren't removed and reset.
    6.              * This is merely automation of described solution. */
    7.             GetComponent<Animator>().enabled = false;
    8.             GetComponent<Animator>().enabled = true;
    9.             GetComponent<Animator>().gameObject.SetActive(true);  // this is actually  not needed in this case
    10.        
    11.         }
     
    SugoiDev, nuverian and altschuler like this.