private object PlayClip(Animation controller, AnimationClip clip)
        {
            if (controller == null || !controller.isActiveAndEnabled || clip == null)
            {
                return(null);
            }

            var id = "aux*" + clip.GetInstanceID();
            var a  = controller[id];

            if (a == null || a.clip != clip)
            {
                controller.AddClip(clip, id);
            }

            AnimationState anim;

            if (_crossFadeDur > 0f)
            {
                anim = controller.CrossFadeQueued(id, _crossFadeDur, _queueMode, _playMode);
            }
            else
            {
                anim = controller.PlayQueued(id, _queueMode, _playMode);
            }
            if (_settingsMask != 0)
            {
                _settings.Apply(anim, _settingsMask);
            }
            return(anim);
        }
Exemplo n.º 2
0
        private object PlayClip(SPAnimationController controller, UnityEngine.Object clip)
        {
            if (clip is AnimationClip)
            {
                var anim = controller.CreateAuxiliarySPAnim(clip as AnimationClip);
                if (_applyCustomSettings)
                {
                    _settings.Apply(anim);
                }
                if (_crossFadeDur > 0f)
                {
                    anim.CrossFade(_crossFadeDur, _queueMode, _playMode);
                }
                else
                {
                    anim.Play(_queueMode, _playMode);
                }
                return(anim);
            }
            else if (clip is IScriptableAnimationClip)
            {
                return(controller.Play(clip as IScriptableAnimationClip));
            }

            return(null);
        }
        private object PlayClip(object controller, UnityEngine.Object clip)
        {
            if (clip is AnimationClip)
            {
                if (controller is SPAnimationController)
                {
                    var anim = (controller as SPAnimationController).CreateAuxiliarySPAnim(clip as AnimationClip);
                    _settings.Apply(anim);
                    if (_crossFadeDur > 0f)
                    {
                        anim.CrossFade(_crossFadeDur, _queueMode, _playMode);
                    }
                    else
                    {
                        anim.Play(_queueMode, _playMode);
                    }
                    return(anim);
                }
                else if (controller is Animation)
                {
                    var animController = controller as Animation;
                    var id             = "aux*" + clip.GetInstanceID();
                    var a = animController[id];
                    if (a == null || a.clip != clip)
                    {
                        animController.AddClip(clip as AnimationClip, id);
                    }

                    AnimationState anim;
                    if (_crossFadeDur > 0f)
                    {
                        anim = animController.CrossFadeQueued(id, _crossFadeDur, _queueMode, _playMode);
                    }
                    else
                    {
                        anim = animController.PlayQueued(id, _queueMode, _playMode);
                    }
                    _settings.Apply(anim);
                    return(anim);
                }
            }
            else if (clip is IScriptableAnimationClip)
            {
                if (controller is SPAnimationController)
                {
                    return((controller as SPAnimationController).Play(clip as IScriptableAnimationClip));
                }
            }

            return(null);
        }
Exemplo n.º 4
0
        public string CrossFadeAuxiliaryDirectly(AnimationClip clip, AnimSettings settings, float fadeLength, PlayMode playMode = PlayMode.StopSameLayer, string auxId = null)
        {
            if (_animation == null)
            {
                throw new AnimationInvalidAccessException();
            }
            if (clip == null)
            {
                throw new System.ArgumentNullException("clip");
            }
            if (!_initialized)
            {
                this.Init();
            }
            if (this.ControllerMask != null && !this.ControllerMask.CanPlay(clip, settings))
            {
                return(null);
            }

            var id   = this.AddAuxiliaryClip(clip, auxId);
            var anim = _animation[id];

            settings.Apply(anim);
            this.CrossFadeInternal(id, fadeLength, playMode, anim.layer);
            return(id);
        }
Exemplo n.º 5
0
        public SPAnim CrossFadeAuxiliary(AnimationClip clip, AnimSettings settings, float fadeLength, QueueMode queueMode = QueueMode.PlayNow, PlayMode playMode = PlayMode.StopSameLayer, string auxId = null)
        {
            if (_animation == null)
            {
                throw new AnimationInvalidAccessException();
            }
            if (clip == null)
            {
                throw new System.ArgumentNullException("clip");
            }
            if (!_initialized)
            {
                this.Init();
            }
            if (this.ControllerMask != null && !this.ControllerMask.CanPlay(clip, settings))
            {
                return(null);
            }

            var id   = this.AddAuxiliaryClip(clip, auxId);
            var anim = SPAnim.Create(_animation, id);

            settings.Apply(anim);
            anim.CrossFade(fadeLength, queueMode, playMode);
            return(anim);
        }