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()
    {

    }

}