using DG.Tweening; using System.Collections; using System.Collections.Generic; using UnityEngine; public class ObjectJump : MonoBehaviour { public RectTransform rect; [Range(-1, 1f)] public float jump = 1f; [Range(0, 3f)] public float duration = 0.5f; public bool END_SHOW = false; public void OnInitialized(Transform targetStart, Transform targetEnd, float delay, System.Action OnEnd = null) { if (rect == null) rect = GetComponent(); transform.position = targetStart.position; gameObject.SetActive(true); rect.DOJump(targetEnd.position, jump, 1, duration).SetDelay(delay).OnComplete(() => { if (OnEnd != null) OnEnd(); gameObject.SetActive(END_SHOW); }); } public void OnInitialized(Vector3 targetStart, Vector3 targetEnd, float delay, System.Action OnEnd = null) { if (rect == null) rect = GetComponent(); rect.anchoredPosition = targetStart; gameObject.SetActive(true); Debug.LogWarning($"{name} : {targetStart} -> {targetEnd}"); //rect.anchoredPosition = targetEnd; rect.DOMove(targetEnd, duration).SetDelay(delay).OnComplete(() => { if (OnEnd != null) OnEnd(); gameObject.SetActive(END_SHOW); }); } }