Build TravelRun intro and tutorial flow
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class FlowIntroStampMotion : MonoBehaviour
|
||||
{
|
||||
private const float Duration = 0.18f;
|
||||
|
||||
private RectTransform rectTransform;
|
||||
private Vector3 baseScale = Vector3.one;
|
||||
private float startTime = -1f;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
rectTransform = GetComponent<RectTransform>();
|
||||
if(rectTransform != null)
|
||||
{
|
||||
baseScale = rectTransform.localScale;
|
||||
}
|
||||
}
|
||||
|
||||
public void Play()
|
||||
{
|
||||
if(rectTransform == null)
|
||||
{
|
||||
rectTransform = GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
if(rectTransform != null)
|
||||
{
|
||||
baseScale = Vector3.one;
|
||||
rectTransform.localScale = baseScale * 1.42f;
|
||||
}
|
||||
|
||||
startTime = Time.unscaledTime;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if(rectTransform == null || startTime < 0f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float t = Mathf.Clamp01((Time.unscaledTime - startTime) / Duration);
|
||||
float scale = Mathf.Lerp(1.42f, 1f, 1f - Mathf.Pow(1f - t, 3f));
|
||||
rectTransform.localScale = baseScale * scale;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user