using System; using System.Collections; using System.Collections.Generic; using Cute; using UnityEngine; public class UIBase : MonoBehaviour { private bool loadOk; private bool isAssetSetting; private bool isOpen; private List m_loadBackgroundList = new List(); private UIManager.ViewScene backSceneSave; protected bool IsShowFooterMenu { get; set; } private void Start() { IsShowFooterMenu = false; onFirstStart(); } private void FixedUpdate() { assetBundleSetting(); onMove(); } public virtual bool IsGetOutOfScene(Action backupExec) { return true; } public virtual bool IsUseCommonBackground() { return false; } protected virtual void OnDestroy() { UnloadBackground(); } private void assetBundleSetting() { if (!loadOk) { StartCoroutine(assetSetting()); loadOk = true; assetBundleEnd(); } } public bool GetloadOk() { return loadOk; } public IEnumerator assetSetting() { if (isAssetSetting) { yield return null; } isAssetSetting = true; bool flag = UIManager.GetInstance().IsCurrentScene(UIManager.ViewScene.Battle); UIManager.GetInstance().AttachAtlas(base.gameObject, !flag); SetBackground(); } private void SetBackground() { ResourcesManager resMgr = Toolbox.ResourcesManager; UIBase_Textuer[] componentsInChildren = base.gameObject.GetComponentsInChildren(includeInactive: true); foreach (UIBase_Textuer bgTex in componentsInChildren) { string texName = bgTex.TextuerName; string assetTypePath = resMgr.GetAssetTypePath(texName, ResourcesManager.AssetLoadPathType.Background); m_loadBackgroundList.Add(assetTypePath); resMgr.StartCoroutine_LoadAssetGroupAsync(assetTypePath, delegate { if (bgTex != null) { bgTex.GetComponent().mainTexture = resMgr.LoadObject(resMgr.GetAssetTypePath(texName, ResourcesManager.AssetLoadPathType.Background, isfetch: true)); } }); } } private void UnloadBackground() { Toolbox.ResourcesManager.RemoveAssetGroup(m_loadBackgroundList); m_loadBackgroundList.Clear(); } protected void resetAssetBaundleSetting() { loadOk = false; isAssetSetting = false; UnloadBackground(); } public virtual void onFirstStart() { Open(); } public void Open() { if (!isOpen) { isOpen = true; if (IsShowFooterMenu) { UIManager.GetInstance().ShowFooterMenu(isShow: true); } } onOpen(); } protected virtual void onOpen() { if (base.transform.localScale.x != 1f) { base.transform.localScale = new Vector3(1f, 1f, 1f); } } public void Close() { if (isOpen) { isOpen = false; if (IsShowFooterMenu) { UIManager.GetInstance().ShowFooterMenu(isShow: false); } onClose(); } } protected virtual void onClose() { if (GameMgr.GetIns() != null && GameMgr.GetIns().GetInputMgr() != null) { GameMgr.GetIns().GetInputMgr().isBackKeyEnable = true; } } public virtual void onMove() { } public virtual void PushTurnButton() { } public virtual void assetBundleEnd() { } public virtual void deleteAction() { } public void setBackScene(UIManager.ViewScene scene) { backSceneSave = scene; } public UIManager.ViewScene getBackScene() { return backSceneSave; } public virtual List GetButtonList() { return null; } }