Search Unity

Creating an Animator Controller in an Editor Script?

Discussion in 'Scripting' started by infinitypbr, Oct 22, 2014.

  1. infinitypbr

    infinitypbr

    Joined:
    Nov 28, 2012
    Posts:
    3,149
    Hello,

    I'm trying to add an animator controller (A new one, not a prefab) when I click a button in an editor script I'm working on. However, I can't seem to crack it. I'm using UnityScript, and my code is:

    Code (csharp):
    1. varnewController = newRuntimeAnimatorController();
    2. AssetDatabase.CreateAsset(newController, "Assets/Animators/test.asset");
    Anyone know where I'm going wrong?
     
  2. LovePurple

    LovePurple

    Joined:
    Jan 3, 2013
    Posts:
    11
    I find solution:

    AnimatorController animatiorCtrl = AnimatorController.CreateAnimatorControllerAtPath("Assets/" + animatorName);