Files

38 lines
940 B
C#

using System;
using System.Collections;
using Cysharp.Threading.Tasks;
using UnityEngine;
namespace Animations
{
public class CoRoutineTween : MonoBehaviour
{
private async void Start()
{
// StartCoroutine(Animate());
await Animate();
}
private IEnumerator Animate()
{
float time = 0.0f;
// move
while (time < 1.0f)
{
transform.position = Vector3.Lerp(Vector3.zero, Vector3.forward * 5.0f, time);
yield return null;
time += Time.deltaTime;
}
// scale
time = 0.0f;
while (time < 1.0f)
{
transform.localScale = Vector3.Lerp(Vector3.one, Vector3.one * 2.0f, time);
yield return null;
time += Time.deltaTime;
}
}
}
}