Esempio n. 1
0
        public void Play(AnimationClip clip, GameObject go, bool isLooping = false)
        {
            this.animationClip = clip;
            this.go            = go;
            this.isLooping     = isLooping;

            if (this.animationClip.legacy == false)
            {
                animator             = go.GetComponentInChildren <Animator>();
                animator.fireEvents  = false;
                animator.logWarnings = false;
                animator.enabled     = false;
                animator.cullingMode = AnimatorCullingMode.AlwaysAnimate;

                RuntimeAnimatorController runtimeAnimatorController = animator.runtimeAnimatorController;
                hasState = false;
                if (runtimeAnimatorController != null)
                {
                    foreach (AnimationClip item in runtimeAnimatorController.animationClips)
                    {
                        if (item.name == clip.name)
                        {
                            hasState = true;
                        }
                    }
                }
                if (hasState == false)
                {
                    parentEditorWindow.ShowNotification(new GUIContent("animator not exist state:" + clip.name));
                }
            }
            else
            {
                hasState = false;
                animator = null;
            }

            _runningTime = 0;
            _duration    = clip.length;
            EditorTickManager.Add(update);
        }