using System; using Cute; using UnityEngine; namespace Wizard; public class TweenPositionWithUpdate : TweenPosition { private Action _onUpdate; public static TweenPosition Begin(GameObject go, float duration, Vector3 pos, Action onUpdate) { TweenPositionWithUpdate tweenPositionWithUpdate = UITweener.Begin(go, duration); tweenPositionWithUpdate.from = tweenPositionWithUpdate.value; tweenPositionWithUpdate.to = pos; if (duration <= 0f) { tweenPositionWithUpdate.Sample(1f, isFinished: true); tweenPositionWithUpdate.enabled = false; } tweenPositionWithUpdate._onUpdate = onUpdate; return tweenPositionWithUpdate; } public static TweenPosition Begin(GameObject go, float duration, Vector3 pos, bool worldSpace, Action onUpdate) { TweenPositionWithUpdate tweenPositionWithUpdate = UITweener.Begin(go, duration); tweenPositionWithUpdate.worldSpace = worldSpace; tweenPositionWithUpdate.from = tweenPositionWithUpdate.value; tweenPositionWithUpdate.to = pos; if (duration <= 0f) { tweenPositionWithUpdate.Sample(1f, isFinished: true); tweenPositionWithUpdate.enabled = false; } tweenPositionWithUpdate._onUpdate = onUpdate; return tweenPositionWithUpdate; } protected override void OnUpdate(float factor, bool isFinished) { base.value = from * (1f - factor) + to * factor; _onUpdate.Call(factor); } }