Esempio n. 1
0
 void Start()
 {
     Mov          = 4;
     des          = transform.position;
     ButtonPic    = Resources.Load <Sprite>("Sprite/Foot");
     ctActionCtrl = GetComponent <CharaterActionCtrl>();
     m_Character  = GetComponent <AnimCtrl>();
 }
Esempio n. 2
0
 public void Destory()
 {
     AnimCtrl?.Destory();
     GameObject.Destroy(gameObject);
 }
        private void OnGUI()
        {
            var rect = new Rect(10, 10, 230, 20);

            EditorGUI.SelectableLabel(rect, "Animation Clips");
            rect  = new Rect(10, 30, 230, 130);
            clips = DevilEditorUtility.TextArea(rect, clips, " List-out Animation Clips");
            rect  = new Rect(40, 165, 80, 30);
            if (GUI.Button(rect, "Create"))
            {
                GUI.FocusControl(null);
                arr.Clear();
                if (string.IsNullOrEmpty(clips) || !StringUtil.ParseArray(clips, arr, '\n'))
                {
                    return;
                }
                if (controller == null || string.IsNullOrEmpty(path))
                {
                    EditorUtility.DisplayDialog("Error", "Can't find controller.", "OK");
                    return;
                }
                var oldassets = AssetDatabase.LoadAllAssetsAtPath(path);
                foreach (var t in arr)
                {
                    if (string.IsNullOrEmpty(t))
                    {
                        continue;
                    }
                    var old = GlobalUtil.Find(oldassets, (x) => x.name == t);
                    if (old != null)
                    {
                        continue;
                    }
                    var clip = AnimCtrl.AllocateAnimatorClip(t);
                    AssetDatabase.AddObjectToAsset(clip, controller);
                }
                AssetDatabase.ImportAsset(path);
                Close();
            }
            rect = new Rect(130, 165, 80, 30);
            if (GUI.Button(rect, "Delete"))
            {
                GUI.FocusControl(null);
                arr.Clear();
                if (string.IsNullOrEmpty(clips) || !StringUtil.ParseArray(clips, arr, '\n'))
                {
                    return;
                }
                if (controller == null || string.IsNullOrEmpty(path))
                {
                    EditorUtility.DisplayDialog("Error", "Can't find controller.", "OK");
                    return;
                }
                var oldassets = AssetDatabase.LoadAllAssetsAtPath(path);
                foreach (var t in arr)
                {
                    if (string.IsNullOrEmpty(t))
                    {
                        continue;
                    }
                    var old = GlobalUtil.Find(oldassets, (x) => x is AnimationClip && x.name == t);
                    if (old == null)
                    {
                        continue;
                    }
                    Object.DestroyImmediate(old, true);
                }
                AssetDatabase.ImportAsset(path);
                Close();
            }
        }