Skip to content
Snippets Groups Projects
Select Git revision
  • 75c0e679698a92526fe13f4c6f2cc0f0a0f6eb00
  • main default
  • master
  • tempAndrToMaster
4 results

resources_contact.html.meta

Blame
  • ImageHintAnimation.cs 1.20 KiB
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;
    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
        void Awake()
        {
            if (imageToChange != null)
                imageToChangeDefaultColor = imageToChange.color;
        }
    
        public void AnimationTrigger()
        {
            routine = Animation();
            StartCoroutine(routine);
    
            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;
            }
        }
    
        public void ResetAnimation()
        {
            if (routine != null)
                StopCoroutine(routine);
        }
    }