// Update is called once per frame void Update() { if (state == StatePopup.FADING) { timer -= Time.deltaTime; float newAlpha = Mathf.Lerp(0, 1, timer / durationFading); SetAlpha(newAlpha); if (timer < 0) { state = StatePopup.INVISIBLE; } } if (state == StatePopup.VISIBLE) { timer -= Time.deltaTime; if (timer < 0) { state = StatePopup.FADING; timer = durationFading; } } }
public void Show() { timer = durationVisible; state = StatePopup.VISIBLE; //Alpha is opaque SetAlpha(1f); AudioManager.Instance.PlaySound(noiseOnShow); }
public void Hide() { timer = 0f; state = StatePopup.INVISIBLE; SetAlpha(0f); }