using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace BITKit.UX { public class UXTranslucentService : MonoBehaviour { [SerializeField] private Image image; private float alpha; private void Start() { BITAppForUnity.AllowCursor.AddListener(OnCursor); destroyCancellationToken.Register(Dispose); } private void Dispose() { BITAppForUnity.AllowCursor.RemoveListener(OnCursor); } private void OnCursor(bool obj) { image.enabled = obj; if (obj) alpha = 0; } private void LateUpdate() { if (BITAppForUnity.AllowCursor.Allow && alpha is not 1) { alpha = Mathf.Clamp01(alpha + Time.deltaTime*5); image.color = new Color(0, 0, 0, alpha); } } } }