コード例 #1
0
    // AnimatorController作成.
    private static RuntimeAnimatorController CreateController(AnimationClip animClip, string resPath)
    {
        var definition = new AnimatorControllerDefinition();

        definition.MotionList.Add(animClip);
        definition.LayerName   = "Base Layer";
        definition.ResulutPath = resPath;
        Debug.Log(" >Create AnimatorContoller Success!!\n  State=" + definition.MotionList[0].name + "\n  LayerName=" + definition.LayerName + "\n  ResulutPath=" + definition.ResulutPath);
        return(CreateController(definition));
    }
コード例 #2
0
    // AnimatorController作成.
    private static RuntimeAnimatorController CreateWalkController(BlendTree blendTree, string resPath)
    {
        var definition = new AnimatorControllerDefinition();

        definition.MotionList.Add(blendTree);
        definition.LayerName   = "Base Layer";
        definition.ResulutPath = resPath;
        definition.ParameterList.Add(new AnimatorControllerParameter {
            type         = AnimatorControllerParameterType.Float,
            name         = "Degree",
            defaultFloat = 90f,
        });
        Debug.Log(" >Create AnimatorContoller Success!!\n  State=" + definition.MotionList[0].name + "\n  LayerName=" + definition.LayerName + "\n  ResulutPath=" + definition.ResulutPath);
        return(CreateController(definition));
    }
コード例 #3
0
    // AnimatorController作成.
    private static RuntimeAnimatorController CreateController(AnimatorControllerDefinition definition)
    {
        AnimatorController animatorController = AnimatorController.CreateAnimatorControllerAtPath(definition.ResulutPath);

        // ステート追加.
        AnimatorStateMachine stateMachine = animatorController.layers[0].stateMachine;

        foreach (Motion motion in definition.MotionList)
        {
            AnimatorState state = stateMachine.AddState(motion.name);
            state.motion = motion;
        }
        // パラメータ追加.
        foreach (var p in definition.ParameterList)
        {
            animatorController.AddParameter(p);
        }

        // 保存.
        EditorUtility.SetDirty(animatorController);
        AssetDatabase.SaveAssets(); // 念のためAssetの更新をかけておく.

        return(animatorController);
    }