using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class UITweenPostion : MonoBehaviour { public float speed = 1; public float time = 1; public Vector3 startPos; public Vector3 endPos; public bool isLoop = false; public void Start() { StartCoroutine(Move()); } IEnumerator Move() { float t = 0; while (t < time) { t += Time.deltaTime * speed; transform.position = Vector3.Lerp(startPos, endPos, t / time); yield return null; } if (isLoop) { StartCoroutine(Move()); } } }