Search Unity

AnimationControllerBuilder default float setter broken?

Discussion in 'Animation' started by jaybennett, Feb 20, 2017.

  1. jaybennett

    jaybennett

    Joined:
    Jul 10, 2012
    Posts:
    165
    I am using the AnimationController.CreateAnimatorControllerAtPath() method to build an animation controller from within an Editor script.

    It appears that using AddParameter() to add a float parameter and then setting that parameter's defaultFloat does not work.

    Reproduce with this code:

    Code (CSharp):
    1. [MenuItem ("Animation/Build Animator Controller")]
    2. static void CreateController () {        
    3.  
    4.     // Creates the controller
    5.     var controller = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerAtPath ("Assets/Packages/CharacterAnimation/AnimController.controller");
    6.  
    7.     // Add parameters
    8.     controller.AddParameter("AnimationSpeed", AnimatorControllerParameterType.Float);
    9.     controller.parameters[0].defaultFloat = 1f;
    10.  
    11.     Debug.Log("name=" + controller.parameters[0].name + " type=" + controller.parameters[0].type + " defaultFloat=" + controller.parameters[0].defaultFloat);
    12. }
    Output:

    Code (csharp):
    1.  
    2. name=AnimationSpeed type=Float defaultFloat=0
    3.  
    Right now I have to go into the AnimatorController after the build and manually set the default AnimationSpeed parameter, which is very annoying!

    Just upgraded to unity 5.5 latest and still seeing this issue (after coming from 5.3).