首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

unity动画片指定器

2012-07-01 
unity动画指定器using UnityEngineusing UnityEditorusing System.Collections/// summary/// 模型动

unity动画指定器

using UnityEngine;using UnityEditor;using System.Collections;/// <summary>/// 模型动画 分配器/// </summary>public class AnimationAssigner : EditorWindow{    static readonly string STR_MYNAME = "模型动画2Prefab";    static readonly string STR_TARGET = "Project中的模型";    static readonly string STR_PREFAB = "场景中的prefab";    static readonly string STR_OK = "开始";    static readonly string STR_INTRODUCE = "将Project中模型的动画,直接复制到场景的某Prefab中.";    //分离好动画的模型,Project内    GameObject model;    //需要指定动画的 prefab.Hierarchy内    GameObject prefab;    [MenuItem("Level4/AnimationTool/ModelAnimationAssign")]    static void Init()    {        EditorWindow.GetWindow<AnimationAssigner>(false,STR_MYNAME);    }    void OnGUI()    {        GUILayout.Box(STR_INTRODUCE);        model = EditorGUILayout.ObjectField(STR_TARGET, model, typeof(GameObject), true) as GameObject;        prefab = EditorGUILayout.ObjectField(STR_PREFAB, prefab, typeof(GameObject), true) as GameObject;        if (GUILayout.Button(STR_OK))        {            if (model != null && prefab != null)            {                if (prefab.animation == null)                    prefab.AddComponent<Animation>();                AnimationUtility.SetAnimationClips(prefab.animation, AnimationUtility.GetAnimationClips(model.animation));                ShowNotification(new GUIContent("完成指定:" + prefab.animation.GetClipCount()));            }        }    }    void OnSelectionChange()    {    }}

热点排行