using System.Collections; using System.Collections.Generic; using Cysharp.Threading.Tasks; using TMPro; using UnityEngine; using UnityEngine.UI; using UnityEngine.UIElements; using Button = UnityEngine.UI.Button; using Image = UnityEngine.UI.Image; using Toggle = UnityEngine.UI.Toggle; using ScrollView = PhxhSDK.PhxhScrollView; using Framework; using DG.Tweening; public class UI_TransitionController : UIWindow { //UI GameObj ///Auto Gen Start/// public Image Image_Content; public TMP_Text Text_Title; public TMP_Text Text_Yes; public Image Image_Mask; public Image Image_MaskWhite; ///Auto Gen End/// public enum ShowType { TitleOnly, //仅显示中间标题 BlackOnly, //仅黑屏 WhiteOnly, } private ShowType _type; private GameObject _goBlack; private GameObject _goTitle; //界面打开外部调用 public static async UniTask Open(int input) { return await UIManager.Instance.CreateAndOpenWindow(UINameConst.UI_Transition, input); } public static async UniTask Open(ShowType showType) { return await UIManager.Instance.CreateAndOpenWindow(UINameConst.UI_Transition, showType); } // deal with input data public override void PreLoad(object data = null) { if (data is ShowType showType) { _type = showType; } else if (data is int showInt) { _type = (ShowType)showInt; } } // Use this for initialization public override void OnInit() { //bind UI GameObj UI_TransitionBinder.GetComponents(this); _goBlack = FindObj("Mask"); _goTitle = FindObj("Content"); Image_Mask.raycastTarget = ShowTransitionMgr.Instance.IsField; Image_MaskWhite.raycastTarget = ShowTransitionMgr.Instance.IsField; } //invoke when open window protected override void OnShowWindow(object data = null) { _ShowPanel(); } //invoke when reload window protected override void OnReloadWindow(object data = null) { } //invoke when close window protected override void OnHideWindow() { } //invoke when destroy public override void OnRelease() { base.OnRelease(); } #region #API public async UniTask EnterBlack(float time = 0.5f) { //Image_Mask.color = Color.black; Image_Mask.DOFade(1, time); await UniTask.Delay((int)(time * 1000)); } public async UniTask ExitBlack(float time = 0.5f) { //Image_Mask.color = Color.black; Image_Mask.DOFade(0, time); await UniTask.Delay((int)(time * 1000)); } public async UniTask EnterWhite(float time = 0.5f) { //Image_Mask.color = Color.white; Image_Mask.DOFade(1, time); await UniTask.Delay((int)(time * 1000)); } public async UniTask ExitWhite(float time = 0.5f) { //Image_Mask.color = Color.white; Image_Mask.DOFade(0, time); await UniTask.Delay((int)(time * 1000)); } #endregion #region #Show private void _ShowPanel() { switch (_type) { case ShowType.BlackOnly: { _ShowBlack(); break; } case ShowType.WhiteOnly: { _ShowWhite(); break; } } } private void _ShowBlack() { Image_Mask.color = new Color(0,0,0,0); _goBlack.SetActive(true); Image_Mask.gameObject.SetActive(true); Image_MaskWhite.gameObject.SetActive(false); _goTitle.SetActive(false); } private void _ShowWhite() { // _goBlack.SetActive(true); // Image_Mask.gameObject.SetActive(false); // Image_MaskWhite.gameObject.SetActive(true); // _goTitle.SetActive(false); Image_Mask.color = new Color(1,1,1,0); _goBlack.SetActive(true); Image_Mask.gameObject.SetActive(true); Image_MaskWhite.gameObject.SetActive(false); _goTitle.SetActive(false); } #endregion }