依旧博客新手,没有那么老练的文字描述以及层层递进水准,所以暂且所有解释性内容均在代码里进行比较详细的说明,文末附上工程链接。
/*
* QQ:765459020
*
* 用代码生成animator控制器
*
* 这里所用资源为Unity自带的2D素材
* 为了方便,我们取其中的Idle和Run两个animation进行操作
* 取Idle为默认状态,Run停止时返回Idle状态
* PS:编辑器并未考虑性能问题
*
* 2016-02-15
*
*/
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
//文件读写
using System.IO;
//Unity基础编辑器
using UnityEditor;
//Unity基础动画编辑
using UnityEditor.Animations;
public class BuildingAnimator : MonoBehaviour
{
//读取动画地址,为了方便,暂且将创建的animator放在该文件夹内
private static string ReadExamplePath = Application.dataPath + "/Standard Assets/2D/Animations/";
//创造animator地址
private static string CreateExamplePath = "Assets/Standard Assets/2D/Animations/";
//创建的animator名字,这里一定要注意加后缀".controller"
private const string ANIMATOR_NAME = "Example_Animator.controller";
private const string ID