コード例 #1
0
        public void CrossFadeDirectly(float fadeLength, PlayMode mode = PlayMode.StopSameLayer)
        {
            if (_controller == null)
            {
                return;
            }

            if (_clip is AnimationClip)
            {
                if (_state == null)
                {
                    //this.Dispose();
                    //throw new System.InvalidOperationException("This clip was unexpectedly destroyed, make sure the animation hasn't been destroyed, or another clip was added with the same name.");
                    return;
                }

                _state.weight    = _weight;
                _state.speed     = _speed * _controller.Speed;
                _state.layer     = _layer;
                _state.wrapMode  = _wrapMode;
                _state.blendMode = _blendMode;
                _controller.CrossFadeInternal(_state.name, fadeLength, mode, _layer);
            }
            else
            {
                var state = SPAnimationController.CreateScriptableAnimState(_controller, _clip as IScriptableAnimationClip);
                state.Layer = _layer;
                state.Play(QueueMode.PlayNow, mode);
            }
        }
コード例 #2
0
        public void Init(SPAnimationController controller, string uniqueHash = null)
        {
            if (controller == null)
            {
                throw new System.ArgumentNullException("container");
            }
            if (this.Initialized)
            {
                throw new System.InvalidOperationException("SPAnimClipCollection already has been initilized.");
            }
            _controller = controller;
            _uniqueHash = uniqueHash;

            bool isMaster = (_controller.States == this);

            if (isMaster)
            {
                _uniqueHash = null;           //master lists aren't allowed a unique hash, the point of the has is for non-master lists
            }
            var e = _dict.GetEnumerator();

            while (e.MoveNext())
            {
                if (isMaster)
                {
                    this.AddToMasterList(e.Current.Value.Name, e.Current.Value, true);
                }
                else
                {
                    e.Current.Value.Init(_controller, _uniqueHash);
                }
            }
        }
コード例 #3
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);
        }
コード例 #4
0
        private object PlayClip(SPAnimationController controller, UnityEngine.Object clip)
        {
            if (controller == null || !controller.isActiveAndEnabled || clip == null)
            {
                return(null);
            }

            if (clip is AnimationClip)
            {
                if (_crossFadeDur > 0f)
                {
                    return(controller.CrossFadeAuxiliary(clip as AnimationClip,
                                                         (_settingsMask != 0) ? AnimSettings.Intersect(AnimSettings.Default, _settings, _settingsMask) : AnimSettings.Default,
                                                         _crossFadeDur, _queueMode, _playMode));
                }
                else
                {
                    return(controller.PlayAuxiliary(clip as AnimationClip,
                                                    (_settingsMask != 0) ? AnimSettings.Intersect(AnimSettings.Default, _settings, _settingsMask) : AnimSettings.Default,
                                                    _queueMode, _playMode));
                }
            }
            else if (clip is IScriptableAnimationClip)
            {
                return(controller.Play(clip as IScriptableAnimationClip));
            }

            return(null);
        }
 public virtual void Dispose()
 {
     _controller = null;
     if (_scheduler != null)
     {
         _scheduler.Dispose();
     }
 }
コード例 #6
0
 public ScriptableAnimState(SPAnimationController controller)
 {
     if (object.ReferenceEquals(controller, null))
     {
         throw new System.ArgumentNullException("controller");
     }
     _controller = controller;
 }
コード例 #7
0
 public void Configure(SPAnimationController controller)
 {
     if (_initialized)
     {
         throw new System.InvalidOperationException("Can not change the Controller of an SPAnimator once it's been initialized.");
     }
     _controller = controller;
 }
コード例 #8
0
 public void Dispose()
 {
     if (_scheduler != null)
     {
         _scheduler.Dispose();
         _scheduler = null;
     }
     _controller = null;
     _routine    = null;
 }
コード例 #9
0
 public void Dispose()
 {
     if (_controller != null && _state != null && _controller.animation[_state.name] == _state)
     {
         _controller.animation.RemoveClip(_state.name);
     }
     _controller = null;
     _state      = null;
     _masks.SetState(null);
 }
コード例 #10
0
 public IEnumerable <Transform> GetTransforms(SPAnimationController controller)
 {
     foreach (var entry in _masks)
     {
         var t = controller.transform.Find(entry.Path);
         if (t != null)
         {
             yield return(t);
         }
     }
 }
コード例 #11
0
 public void Apply(SPAnimationController controller, AnimationState state)
 {
     foreach (var entry in _masks)
     {
         var t = controller.transform.Find(entry.Path);
         if (t != null)
         {
             state.AddMixingTransform(t, entry.Recurse);
         }
     }
 }
コード例 #12
0
 public void Redact(SPAnimationController controller, AnimationState state)
 {
     foreach (var entry in _masks)
     {
         var t = controller.transform.Find(entry.Path);
         if (t != null)
         {
             state.RemoveMixingTransform(t);
         }
     }
 }
コード例 #13
0
        public void Dispose()
        {
            var nm = _id; // _state.name;

            if (_controller != null && _state != null && _controller.animation[nm] == _state)
            {
                _controller.animation.RemoveClip(nm);
            }
            _controller = null;
            _state      = null;
            _mask.Value = null;
        }
コード例 #14
0
        public static SPAnim Create(SPAnimationController anim, string clipId)
        {
            if (anim == null)
            {
                throw new System.ArgumentNullException("anim");
            }
            var a = _pool.GetInstance();

            a._controller   = anim;
            a._clipId       = clipId;
            a._timeSupplier = anim.TimeSupplier as ITimeSupplier;
            return(a);
        }
コード例 #15
0
 /// <summary>
 /// Associate the collection as a master collection for an SPAnimationController
 /// </summary>
 /// <param name="controller"></param>
 internal void InitMasterCollection(SPAnimationController controller)
 {
     if (controller == null)
     {
         throw new System.ArgumentNullException("container");
     }
     if (this.Initialized)
     {
         throw new System.InvalidOperationException("SPAnimClipCollection already has been initilized.");
     }
     _controller = controller;
     _uniqueHash = null;
 }
コード例 #16
0
 public void Dispose()
 {
     if (_scheduler != null)
     {
         _scheduler.Dispose();
         _scheduler = null;
     }
     if (_state != null)
     {
         _state.OnStop();
     }
     _controller = null;
     _state      = null;
 }
コード例 #17
0
        public void Dispose()
        {
            if (object.ReferenceEquals(_controller, null))
            {
                return;
            }

            var e = _dict.GetEnumerator();

            while (e.MoveNext())
            {
                e.Current.Value.Dispose();
            }
            _controller = null;
        }
コード例 #18
0
 /// <summary>
 /// This is only called from the Master List after the AnimationClip has been added and initialized.
 /// Do not call for any other reason.
 /// </summary>
 /// <param name="controller"></param>
 /// <param name="id"></param>
 /// <param name="state"></param>
 internal void SetAnimState(SPAnimationController controller, string id, AnimationState state)
 {
     //we reset the controller and id to what the SPAnimationController decided it should be
     _controller = controller;
     _id         = id;
     _state      = state;
     if (_state != null)
     {
         _state.weight    = _weight;
         _state.speed     = _speed;
         _state.layer     = _layer;
         _state.wrapMode  = _wrapMode;
         _state.blendMode = _blendMode;
         _masks.SetState(_state);
     }
 }
コード例 #19
0
        public void Init(SPAnimationController controller, string uniqueHash = null)
        {
            if (_controller != null)
            {
                throw new System.InvalidOperationException("Cannot initialize a clip that has already been initialized.");
            }
            if (controller == null)
            {
                throw new System.ArgumentNullException("controller");
            }
            //if (_clip == null) return;
            //if (_clip == null) _clip = SPAnimClip.EmptyClip;

            _controller = controller;
            _id         = (string.IsNullOrEmpty(uniqueHash)) ? _name : _name + uniqueHash;
            _controller.States.AddToMasterList(_id, this);
        }
コード例 #20
0
        /// <summary>
        /// Initialize a SPAnimClipCollection with a SPAnimationController.
        ///
        /// (internal: this is only used for non-master collections)
        /// </summary>
        /// <param name="controller"></param>
        /// <param name="uniqueHash"></param>
        public void Init(SPAnimationController controller, string uniqueHash = null)
        {
            if (controller == null)
            {
                throw new System.ArgumentNullException("controller");
            }
            if (this.Initialized)
            {
                throw new System.InvalidOperationException("SPAnimClipCollection already has been initilized.");
            }
            _controller = controller;
            _uniqueHash = uniqueHash;

            var e = _dict.GetEnumerator();

            while (e.MoveNext())
            {
                e.Current.Value.Init(_controller, _uniqueHash);
            }
        }
コード例 #21
0
        //***SEE NOTES IN CLASS DESCRIPTION

        //public void SetFrameClamp(int firstFrame, int lastFrame)
        //{
        //    if (_container != null) throw new System.InvalidOperationException("The frame clamp can only be set on a clip that has not been initialized.");

        //    _firstFrame = firstFrame;
        //    _lastFrame = lastFrame;
        //    if (_firstFrame < 0) _firstFrame = 0;
        //    if (_lastFrame < 0) _lastFrame = -1;
        //    else if (_lastFrame < _firstFrame) _lastFrame = _firstFrame + 1;
        //}

        //public void ResetFrameClamp()
        //{
        //    _firstFrame = 0;
        //    _lastFrame = -1;
        //}

        /// <summary>
        /// Creates a state for use in animating.
        /// </summary>
        /// <returns></returns>
        public ISPAnim CreateAnimatableState()
        {
            if (_controller == null)
            {
                throw new System.InvalidOperationException("This clip has not been initialized.");
            }

            if (_clip is AnimationClip)
            {
                if (_state == null)
                {
                    //this.Dispose();
                    //throw new System.InvalidOperationException("This clip was unexpectedly destroyed, make sure the animation hasn't been destroyed, or another clip was added with the same name.");
                    return(null);
                }

                var a = SPAnim.Create(_controller, _id);
                a.Weight    = _weight;
                a.Speed     = _speed;
                a.Layer     = _layer;
                a.WrapMode  = _wrapMode;
                a.BlendMode = _blendMode;
                if (_masks.Count > 0)
                {
                    a.Masks.Copy(_masks);
                }
                if (_timeSupplier.IsCustom)
                {
                    a.TimeSupplier = _timeSupplier.TimeSupplier as ITimeSupplier;
                }
                return(a);
            }
            else if (_clip is IScriptableAnimationClip)
            {
                var a = SPAnimationController.CreateScriptableAnimState(_controller, _clip as IScriptableAnimationClip);
                a.Layer = _layer;
                return(a);
            }

            return(null);
        }
コード例 #22
0
        public void Dispose()
        {
            _controller = null;
            _clipId     = null;
            _weight     = 1f;
            _speed      = 1f;
            _layer      = 0;
            _wrapMode   = UnityEngine.WrapMode.Default;
            _blendMode  = AnimationBlendMode.Blend;
            _masks.Clear();
            this.UnregisterTimeScaleChangedEvent();
            _timeSupplier = null;

            _state = null;
            if (_scheduler != null)
            {
                _scheduler.Clear();
            }

            _pool.Release(this);
        }
コード例 #23
0
        internal static ISPAnim CreateScriptableAnimState(SPAnimationController controller, IScriptableAnimationClip clip)
        {
            if (controller == null)
            {
                throw new System.ArgumentNullException("controller");
            }
            if (clip == null)
            {
                throw new System.ArgumentNullException("clip");
            }

            var st = clip.GetState(controller);

            if (st == null)
            {
                return(SPAnim.Null);
            }

            var state = new ScriptableAnimationStateWrapper();

            state.Init(controller, st);
            return(state);
        }
コード例 #24
0
 protected abstract void Init(SPEntity entity, SPAnimationController controller);
コード例 #25
0
 public ScriptableAnimCollection(SPAnimationController controller)
 {
     _controller = controller;
 }
コード例 #26
0
 public void Init(SPAnimationController controller, IScriptableAnimationState state)
 {
     _controller = controller;
     _state      = state;
     _startTime  = UnityEngine.Time.time;
 }
コード例 #27
0
 public void Init(SPAnimationController controller, RadicalCoroutine routine)
 {
     _controller = controller;
     _routine    = routine;
     _startTime  = UnityEngine.Time.time;
 }