add unity multithreading project
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Animations
|
||||
{
|
||||
public class AsyncTween : MonoBehaviour
|
||||
{
|
||||
private void Start()
|
||||
{
|
||||
Animate();
|
||||
}
|
||||
|
||||
private async UniTask Animate()
|
||||
{
|
||||
float time = 0.0f;
|
||||
|
||||
// move
|
||||
while (time < 1.0f)
|
||||
{
|
||||
transform.position = Vector3.Lerp(Vector3.zero, Vector3.forward * 5.0f, time);
|
||||
// await Task.Delay(100);
|
||||
await UniTask.DelayFrame(1);
|
||||
time += Time.deltaTime;
|
||||
}
|
||||
|
||||
// scale
|
||||
time = 0.0f;
|
||||
while (time < 1.0f)
|
||||
{
|
||||
transform.localScale = Vector3.Lerp(Vector3.one, Vector3.one * 2.0f, time);
|
||||
// await Task.Delay(100);
|
||||
await UniTask.DelayFrame(1);
|
||||
time += Time.deltaTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user