using System.Collections; using System.Collections.Generic; using UnityEngine; public class UIFader : MonoBehaviour { public float FadeTime; private CanvasGroup canvasGroup; private void Awake() { canvasGroup = GetComponent(); } private bool isShow = true; public bool HideOnStart = false; private void Start() { if (HideOnStart) HidePanel(); } private void OnDisable() { LeanTween.cancel(gameObject); } public void ShowPanel() { if (canvasGroup == null) return; //LeanTween.value(0, 1, FadeTime).setOnUpdate((float x) => //{ // canvasGroup.alpha = x; //}); canvasGroup.alpha = 1; canvasGroup.blocksRaycasts = true; isShow = true; } public void HidePanel() { if (canvasGroup == null) return; //LeanTween.value(1, 0, FadeTime).setOnUpdate((float x) => //{ // canvasGroup.alpha = x; //}); canvasGroup.alpha = 0; canvasGroup.blocksRaycasts = false; isShow = false; } public void Toggle() { if (isShow) HidePanel(); else ShowPanel(); } }