You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.4 KiB
51 lines
1.4 KiB
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<RectTransform>(); |
|
|
|
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<RectTransform>(); |
|
|
|
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); |
|
}); |
|
} |
|
}
|
|
|