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 } }
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); } }
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); } }
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)); } }
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); } }
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; } }
public abstract void SetBySmooth(T target, SmoothData sd, ElementStateData esd, float progress);
} // 是否允许渐变 public abstract void InitBySmooth(T target, SmoothData sd);
public override void InitBySmooth(MaskableGraphic target, SmoothData sd) { sd.color32 = target.color; }
public override void InitBySmooth(MaskableGraphic target, SmoothData sd) { sd.vector3.x = target.color.a; }
public override void InitBySmooth(Transform target, SmoothData sd) { sd.vector3 = target.localPosition; }
public override void InitBySmooth(Transform target, SmoothData sd) { sd.vector3 = target.localEulerAngles; }
public override void InitBySmooth(RectTransform target, SmoothData sd) { sd.vector3.x = target.rect.width; }
public override void InitBySmooth(RectTransform target, SmoothData sd) { sd.vector3 = target.anchoredPosition; }
public override void InitBySmooth(CanvasGroup target, SmoothData sd) { sd.vector3.x = target.alpha; }