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); } }
//***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); }