Beispiel #1
0
            void DoUpdate(UIAnim anim, float value)
            {
                if (!this.isCaptured || this.prevValue != value)
                {
                    this.OnUpdate(anim, value);
                }

                this.isCaptured = true;
                this.prevValue  = value;
            }
Beispiel #2
0
            public bool Sample(UIAnim anim, float time, bool foward)
            {
                if (foward)
                {
                    this.UpdateFoward(time);
                }
                else
                {
                    this.UpdateBackward(time);
                }

                return(this.Capture(anim, time, foward));
            }
Beispiel #3
0
            public bool Capture(UIAnim anim, float time, bool foward)
            {
                var current = this[this.position];

                if (null == current)
                {
                    this.done = true;
                    return(false);
                }

                var next = foward ? this[this.position + 1] : this[this.position - 1];

                if (null == next)
                {
                    if (time >= current.Time)
                    {
                        this.DoUpdate(anim, current.Value);
                        this.done = true;
                    }
                    return(false);
                }

                if (!foward)
                {
                    var temp = current;
                    current = next;
                    next    = temp;
                }

                var start    = current.Time;
                var end      = next.Time;
                var duration = end - start;

                var delta = 0 >= duration ? 1 :
                            foward?Mathf.Clamp01((time - start) / duration) :
                                1 - Mathf.Clamp01((time - start) / duration);

                var interpolate = current.Interpolator;
                var t           = null != interpolate?interpolate.Interpolate(delta) : delta;

                var from = current.Value;
                var to   = null != next ? next.Value : from;

                var value = Mathf.Lerp(from, to, t);

                this.DoUpdate(anim, value);
                return(true);
            }
Beispiel #4
0
        public void Play()
        {
            if (!this.playing)
            {
                this.Rewind();
                this.anchorTime = UIAnim.GetSysTime();
            }

            this.playing = true;

            if (this.paused)
            {
                this.paused     = false;
                this.anchorTime = UIAnim.GetSysTime() - this.currentTime;
            }
        }
Beispiel #5
0
        public void Update()
        {
            if (!this.playing)
            {
                return;
            }

            if (this.paused)
            {
                return;
            }

            if (this.totalDuration == 0)
            {
                this.Stop();
                return;
            }
            var sysTime = UIAnim.GetSysTime();

            this.currentTime = (sysTime - this.anchorTime) * this.speed;

            if (this.totalDuration <= this.currentTime)
            {
                if (this.pingpong)
                {
                    this.ChangePingpong(sysTime);
                }
                else if (this.loop)
                {
                    var currentTime = this.currentTime % this.totalDuration;
                    this.Rewind();
                    this.currentTime = currentTime;
                    this.Sample();
                }
                else
                {
                    this.currentTime = this.totalDuration;
                    this.Sample();
                    this.Stop();
                }
            }
            else
            {
                this.Sample();
            }
        }
Beispiel #6
0
            void OnUpdateExtra(float value, UIAnim anim)
            {
                var listener = anim.OnExtraListener;

//#if LOG_DEBUG
//                Debug.Log(string.Format("UIANIM:ON_UPDATE_EXTRA:{0}, CID:{1}, VAL:{2}, POS:{3}, PREV:{4}, IS_CAP:{5}",
//                                         anim,
//                                         customId,
//                                         value,
//                                         this.position,
//                                         this.prevValue,
//                                         this.isCaptured));
//#endif// LOG_DEBUG
                if (null != listener)
                {
                    listener(anim, this.customId, value);
                }
            }
Beispiel #7
0
            void OnUpdate(UIAnim anim, float value)
            {
                switch (this.formula)
                {
                case Formula.AnchoredXY:    this.OnUpdateAnchoredXY(value); break;

                case Formula.AnchoredX:     this.OnUpdateAnchoredX(value); break;

                case Formula.AnchoredY:     this.OnUpdateAnchoredY(value); break;

                case Formula.ScaleXY:       this.OnUpdateScaleXY(value); break;

                case Formula.ScaleX:        this.OnUpdateScaleX(value); break;

                case Formula.ScaleY:        this.OnUpdateScaleY(value); break;

                case Formula.RotateXYZ:     this.OnUpdateRotateXYZ(value); break;

                case Formula.RotateXY:      this.OnUpdateRotateXY(value); break;

                case Formula.RotateXZ:      this.OnUpdateRotateXZ(value); break;

                case Formula.RotateYZ:      this.OnUpdateRotateYZ(value); break;

                case Formula.RotateX:       this.OnUpdateRotateY(value); break;

                case Formula.RotateY:       this.OnUpdateRotateY(value); break;

                case Formula.RotateZ:       this.OnUpdateRotateZ(value); break;

                case Formula.ColorRGBA:     this.OnUpdateColorRGBA(value); break;

                case Formula.ColorRGB:      this.OnUpdateColorRGB(value); break;

                case Formula.ColorRGA:      this.OnUpdateColorRGA(value); break;

                case Formula.ColorRBA:      this.OnUpdateColorRBA(value); break;

                case Formula.ColorRG:       this.OnUpdateColorRG(value); break;

                case Formula.ColorRB:       this.OnUpdateColorRB(value); break;

                case Formula.ColorRA:       this.OnUpdateColorRA(value); break;

                case Formula.ColorGB:       this.OnUpdateColorGB(value); break;

                case Formula.ColorGA:       this.OnUpdateColorGA(value); break;

                case Formula.ColorBA:       this.OnUpdateColorBA(value); break;

                case Formula.ColorR:        this.OnUpdateColorR(value); break;

                case Formula.ColorG:        this.OnUpdateColorG(value); break;

                case Formula.ColorB:        this.OnUpdateColorB(value); break;

                case Formula.ColorA:        this.OnUpdateColorA(value); break;

                case Formula.Index:         this.OnUpdateIndex(value); break;

                case Formula.Sprite:        this.OnUpdateSprite(value); break;

                case Formula.Extra:         this.OnUpdateExtra(value, anim); break;

                case Formula.Anim:          this.OnUpdateAnim(value); break;

                case Formula.FillAmount:    this.OnUpdateFillAmount(value); break;

                case Formula.CanvasA:       this.OnUpdateCanvasA(value); break;
                }

#if UNITY_EDITOR
                if (!UnityEditor.EditorApplication.isPlaying)
                {
                    if (this.transform)
                    {
                        UnityEditor.EditorUtility.SetDirty(this.transform);
                    }
                    if (this.graphic)
                    {
                        UnityEditor.EditorUtility.SetDirty(this.graphic);
                    }
                    if (this.indexable)
                    {
                        UnityEditor.EditorUtility.SetDirty(this.indexable);
                    }
                    if (this.spa)
                    {
                        UnityEditor.EditorUtility.SetDirty(this.spa);
                    }
                }
#endif// UNITY_EDITOR
            }