Newer
Older
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
Marco Zimmer
committed
using static GlobalBehaviour;
public class ImageHintAnimation : MonoBehaviour
{
public Image imageToChange;
[System.NonSerialized]
public Color imageToChangeDefaultColor;
private IEnumerator routine;
// Start is called before the first frame update
{
if (imageToChange != null)
imageToChangeDefaultColor = imageToChange.color;
}
public void AnimationTrigger()
{
routine = Animation();
StartCoroutine(routine);
John Schihada
committed
IEnumerator Animation()
for ( var track = 0f.LerpInTime(0, 0, GlobalBehaviour.hintAnimationDuration)
; track.MoveNext();)
yield return imageToChange.color =
Color.Lerp
( GlobalBehaviour.hintAnimationStartColor
, GlobalBehaviour.hintAnimationEndColor
, Mathf.PingPong(Time.time, 1));
imageToChange.color = imageToChangeDefaultColor;
}
John Schihada
committed
}
public void ResetAnimation()
if (routine != null)
StopCoroutine(routine);