示例#1
0
        public override void Set(Element element, int index)
        {
            if (element.target != null)
            {
                T target             = element.GetTarget <T>();
                ElementStateData esd = element.stateData[index];
                if (esd.isSmooth)
                {
                    SmoothData sd = new SmoothData();
                    InitBySmooth(target, sd);
                    esd.AddFrameUpdate((object p) =>
                    {
                        if (target == null)
                        {
                            return(false);
                        }

#if UNITY_EDITOR
                        if (!Application.isPlaying)
                        {
                            sd.esc_timer += 0.011f;
                        }
                        else
#endif
                        {
                            float deltaTime = Time.deltaTime;
                            sd.esc_timer   += deltaTime;
                        }

                        bool isend     = false;
                        float progress = 1f;
                        if (sd.esc_timer >= esd.smoothTime)
                        {
                            isend = true;
                        }
                        else
                        {
                            progress = sd.esc_timer / esd.smoothTime;
                        }

                        SetBySmooth(target, sd, esd, progress);

#if UNITY_EDITOR
                        EditorUtility.SetDirty(target);
#endif
                        return(!isend);
                    }, null);
                }
                else
                {
                    SetBySmooth(target, null, esd, -1f);
                }

#if UNITY_EDITOR
                EditorUtility.SetDirty(target);
#endif
            }
        }
示例#2
0
 public override void SetBySmooth(MaskableGraphic target, SmoothData sd, ElementStateData esd, float progress)
 {
     if (sd == null)
     {
         target.color = esd.color32;
     }
     else
     {
         target.color = sd.Get(esd.color32, progress);
     }
 }
示例#3
0
 public override void SetBySmooth(Transform target, SmoothData sd, ElementStateData esd, float progress)
 {
     if (sd == null)
     {
         target.localPosition = esd.vector3;
     }
     else
     {
         target.localPosition = sd.Get(esd.vector3, progress);
     }
 }
示例#4
0
 public override void SetBySmooth(RectTransform target, SmoothData sd, ElementStateData esd, float progress)
 {
     if (sd == null)
     {
         target.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, esd.vector3.x);
     }
     else
     {
         target.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, sd.Get(esd.vector3.x, progress));
     }
 }
示例#5
0
 public override void SetBySmooth(CanvasGroup target, SmoothData sd, ElementStateData esd, float progress)
 {
     if (sd == null)
     {
         target.alpha = esd.vector3.x;
     }
     else
     {
         target.alpha = sd.Get(esd.vector3.x, progress);
     }
 }
示例#6
0
 public override void SetBySmooth(MaskableGraphic target, SmoothData sd, ElementStateData esd, float progress)
 {
     if (sd == null)
     {
         Color color = target.color;
         color.a      = esd.vector3.x;
         target.color = color;
     }
     else
     {
         Color color = target.color;
         color.a      = sd.Get(esd.vector3.x, progress);
         target.color = color;
     }
 }
示例#7
0
 public abstract void SetBySmooth(T target, SmoothData sd, ElementStateData esd, float progress);
示例#8
0
        }                                                      // 是否允许渐变

        public abstract void InitBySmooth(T target, SmoothData sd);
示例#9
0
 public override void InitBySmooth(MaskableGraphic target, SmoothData sd)
 {
     sd.color32 = target.color;
 }
示例#10
0
 public override void InitBySmooth(MaskableGraphic target, SmoothData sd)
 {
     sd.vector3.x = target.color.a;
 }
示例#11
0
 public override void InitBySmooth(Transform target, SmoothData sd)
 {
     sd.vector3 = target.localPosition;
 }
示例#12
0
 public override void InitBySmooth(Transform target, SmoothData sd)
 {
     sd.vector3 = target.localEulerAngles;
 }
示例#13
0
 public override void InitBySmooth(RectTransform target, SmoothData sd)
 {
     sd.vector3.x = target.rect.width;
 }
示例#14
0
 public override void InitBySmooth(RectTransform target, SmoothData sd)
 {
     sd.vector3 = target.anchoredPosition;
 }
示例#15
0
 public override void InitBySmooth(CanvasGroup target, SmoothData sd)
 {
     sd.vector3.x = target.alpha;
 }