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

Question How to change animator controller parameter value via editor script?

Discussion in 'Animation' started by a690089735, Dec 3, 2022.

  1. a690089735

    a690089735

    Joined:
    Dec 3, 2022
    Posts:
    10
    I can use code like this to create an animator controller (a file with .controller suffix)
    Code (CSharp):
    1. var controller = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerAtPath("Assets/Mecanim/StateMachineTransitions.controller");
    2. controller.AddParameter("FBBIKWeight", AnimatorControllerParameterType.Float);
    Then select it in the project window, it looks like this:
    upload_2022-12-3_20-55-1.png
    This file is not referenced to any Animator, This is also the result I want, that is, the animator controller is just a .controller file.
    but I want the value of FBBIKWeight to be 1.0, but, not found a function like "animatorcontroller.parameters[0].value = 1.0f".
    Currently I can only change this value in the window, however I have thousands of files, so,how should I set the parameters in the animator controller to 1?
     
  2. a690089735

    a690089735

    Joined:
    Dec 3, 2022
    Posts:
    10