62 lines
1.8 KiB
C#
62 lines
1.8 KiB
C#
using Assets.MyGame.Scripts.Net;
|
||
using Assets.MyGame.Scripts.Net.API;
|
||
using Assets.MyGame.Scripts.Net.APIResponses.Enum;
|
||
using Assets.MyGame.Scripts.Net.WebResponses;
|
||
using Newtonsoft.Json;
|
||
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using TMPro;
|
||
using UnityEngine;
|
||
using UnityEngine.EventSystems;
|
||
using UnityEngine.InputSystem;
|
||
using UnityEngine.SceneManagement;
|
||
using UnityEngine.UI;
|
||
|
||
public class GameMainPanel_Base : UIBase
|
||
{
|
||
|
||
[Header("子ui管理器")]
|
||
public SubUIManager subUIManager;
|
||
public UIPanelAddressConfig panelAddressConfig;
|
||
public Transform subPanelParent;
|
||
public TextMeshProUGUI textMeshProUGUI_RoomID;
|
||
|
||
public virtual void Awake()
|
||
{
|
||
subUIManager = new SubUIManager(subPanelParent, panelAddressConfig,this);
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// ⭐ 面板销毁时释放其子面板的全部 Addressables 资源:
|
||
/// SubUIManager 的 handleCache(VIP/背包/邮件等子面板 prefab)此前从不释放,
|
||
/// 导致父面板关闭后对应 bundle(如 HomeUIRes)一直占着内存。
|
||
/// 放基类上,大厅/各游戏面板销毁时统一生效。
|
||
/// </summary>
|
||
public virtual void OnDestroy()
|
||
{
|
||
try
|
||
{
|
||
subUIManager?.ReleaseAll();
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
// 退出 Play/场景卸载时 Addressables 可能已回收,忽略释放期异常
|
||
Debug.LogWarning($"[GameMainPanel_Base] OnDestroy 释放子面板资源异常: {e.Message}");
|
||
}
|
||
subUIManager = null;
|
||
}
|
||
|
||
#if UNITY_EDITOR
|
||
public void OnGUI()
|
||
{
|
||
if (GameManager.Instance.gameData.currRoomData != null)
|
||
{
|
||
textMeshProUGUI_RoomID.text = GameManager.Instance.gameData.currRoomData.roomId;
|
||
|
||
}
|
||
}
|
||
#endif
|
||
}
|