30 lines
766 B
C#
30 lines
766 B
C#
using System.Collections;
|
|
using Cysharp.Threading.Tasks;
|
|
using UnityEngine;
|
|
|
|
namespace Animations
|
|
{
|
|
public class CoroutineTween : MonoBehaviour
|
|
{
|
|
private async void Start()
|
|
{
|
|
// StartCoroutine(Animate());
|
|
|
|
// with UniTask
|
|
await Animate();
|
|
}
|
|
|
|
private IEnumerator Animate()
|
|
{
|
|
float time = 0.0f;
|
|
|
|
while (time < 1.0f)
|
|
{
|
|
transform.position = Vector3.Lerp(Vector3.zero, transform.forward * 5.0f, time);
|
|
transform.localScale = Vector3.Lerp(Vector3.one, Vector3.one * 2.0f, time);
|
|
yield return null; // wait for next frame
|
|
time += Time.deltaTime;
|
|
}
|
|
}
|
|
}
|
|
} |