Added Unity assets and settings, including animation scripts, audio manager configuration, TextMesh Pro styles, and default volume profiles.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
using System.Collections;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Animations
|
||||
{
|
||||
public class ThreadTween : MonoBehaviour
|
||||
{
|
||||
private void Start()
|
||||
{
|
||||
StartCoroutine(StartThread());
|
||||
}
|
||||
|
||||
private IEnumerator StartThread()
|
||||
{
|
||||
yield return new WaitForSeconds(2.0f);
|
||||
|
||||
// CAUTION: you can't access Unity Objects, e.g. Transforms, from another thread
|
||||
// than the main thread
|
||||
|
||||
// CAUTION: never put the main thread to sleep, e.g. Thread.Sleep() or Thread.Join()
|
||||
|
||||
Vector3 position = transform.position;
|
||||
Vector3 forward = transform.forward;
|
||||
Vector3 localScale = transform.localScale;
|
||||
|
||||
Thread thread = new Thread(() =>
|
||||
{
|
||||
float time = 0.0f;
|
||||
|
||||
while (time < 1.0f)
|
||||
{
|
||||
position = Vector3.Lerp(Vector3.zero, forward * 5.0f, time);
|
||||
localScale = Vector3.Lerp(Vector3.one, Vector3.one * 2.0f, time);
|
||||
Thread.Sleep(16);
|
||||
// time += Time.deltaTime; // Time is not available in a thread
|
||||
time += 0.016f;
|
||||
}
|
||||
});
|
||||
thread.Start();
|
||||
|
||||
thread.Join();
|
||||
|
||||
transform.position = position;
|
||||
transform.localScale = localScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user