You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
886 B

6 years ago
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UltraCombos;
public class ScaleActivity : Activity
{
public float introTime = 1;
public float outroTime = 1;
protected override IEnumerator OnEnter()
{
yield return DoScaling( 1, introTime);
}
protected override IEnumerator OnLeave()
{
yield return DoScaling( 0, outroTime);
}
IEnumerator DoScaling( float to, float totalTime)
{
float from = transform.localScale.x;
float scale = from;
float startTime = Time.time;
while (scale != to)
{
float duration = Time.time - startTime;
scale = Mathf.Lerp(from, to, duration / totalTime);
transform.localScale = new Vector3(scale, scale, 1);
yield return null;
}
yield break;
}
}