36 lines
968 B
C#
36 lines
968 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using DG.Tweening;
|
|
public class DymanicEffect : MonoBehaviour
|
|
{
|
|
public RectTransform Icon;
|
|
float speed=200;
|
|
float time1 = 0;
|
|
public Transform[] tran;
|
|
int i= 0;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
Move(i);
|
|
}
|
|
|
|
void Move(int i)
|
|
{
|
|
i += 1;
|
|
time1 = (Mathf.Abs(tran[i].position.x - this.transform.position.x) + Mathf.Abs(tran[i].position.y - this.transform.position.y)) / speed;
|
|
Icon.transform.rotation = tran[i].rotation;
|
|
Icon.DOMove(tran[i].position, time1).OnComplete(() => {
|
|
if (i <= 7)
|
|
Move(i);
|
|
else
|
|
{
|
|
i = 0;
|
|
Icon.transform.position = tran[0].transform.position;
|
|
Icon.transform.rotation = tran[0].transform.rotation;
|
|
Move(i);
|
|
}
|
|
});
|
|
}
|
|
}
|