Synchronise Twitch Events to your Phillips Hue Lights
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.
 
 
 
Twitchue/Assets/Scripts/UI/PageController.cs

43 lines
855 B

using System.Collections;
using UnityEngine;
public class PageController : MonoBehaviour
{
private CanvasGroup canvasManager;
private void Awake()
{
canvasManager = GetComponent<CanvasGroup>();
}
private IEnumerator Lerp(bool display, float time)
{
float t = 0;
while (t <= time)
{
if (display)
{
canvasManager.alpha = Mathf.Lerp(0, 1, t / time);
}
else
{
canvasManager.alpha = Mathf.Lerp(1, 0, t / time);
}
t += Time.deltaTime;
yield return null;
}
StopCoroutine(Lerp(display, time));
}
public void Display()
{
StartCoroutine(Lerp(true, 5));
}
public void Hide()
{
StartCoroutine(Lerp(false, 5));
}
}