2026-10-09 20:20:14 +08:00
|
|
|
|
using Assets.MyGame.Scripts.Net;
|
2026-03-12 10:48:53 +08:00
|
|
|
|
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;
|
2026-02-03 11:35:19 +08:00
|
|
|
|
using System.Collections.Generic;
|
2026-03-18 17:26:14 +08:00
|
|
|
|
using TMPro;
|
2026-02-03 11:35:19 +08:00
|
|
|
|
using UnityEngine;
|
2026-03-12 10:48:53 +08:00
|
|
|
|
using UnityEngine.EventSystems;
|
|
|
|
|
|
using UnityEngine.InputSystem;
|
|
|
|
|
|
using UnityEngine.SceneManagement;
|
|
|
|
|
|
using UnityEngine.UI;
|
2026-02-03 11:35:19 +08:00
|
|
|
|
|
2026-02-13 19:23:01 +08:00
|
|
|
|
public class GameMainPanel_Base : UIBase
|
2026-02-03 11:35:19 +08:00
|
|
|
|
{
|
2026-10-09 20:20:14 +08:00
|
|
|
|
|
2026-03-12 10:48:53 +08:00
|
|
|
|
[Header("子ui管理器")]
|
2026-02-13 19:23:01 +08:00
|
|
|
|
public SubUIManager subUIManager;
|
|
|
|
|
|
public UIPanelAddressConfig panelAddressConfig;
|
|
|
|
|
|
public Transform subPanelParent;
|
2026-03-18 17:26:14 +08:00
|
|
|
|
public TextMeshProUGUI textMeshProUGUI_RoomID;
|
2026-10-09 20:20:14 +08:00
|
|
|
|
|
2026-02-13 19:23:01 +08:00
|
|
|
|
public virtual void Awake()
|
2026-02-03 11:35:19 +08:00
|
|
|
|
{
|
2026-02-26 11:05:56 +08:00
|
|
|
|
subUIManager = new SubUIManager(subPanelParent, panelAddressConfig,this);
|
2026-10-09 20:20:14 +08:00
|
|
|
|
|
2026-03-12 10:48:53 +08:00
|
|
|
|
}
|
2026-10-09 20:20:14 +08:00
|
|
|
|
|
|
|
|
|
|
/// <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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-18 17:26:14 +08:00
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
|
public void OnGUI()
|
2026-03-12 10:48:53 +08:00
|
|
|
|
{
|
2026-05-02 23:52:48 +08:00
|
|
|
|
if (GameManager.Instance.gameData.currRoomData != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
textMeshProUGUI_RoomID.text = GameManager.Instance.gameData.currRoomData.roomId;
|
2026-03-12 10:48:53 +08:00
|
|
|
|
|
2026-05-02 23:52:48 +08:00
|
|
|
|
}
|
2026-03-12 10:48:53 +08:00
|
|
|
|
}
|
2026-03-18 17:26:14 +08:00
|
|
|
|
#endif
|
2026-02-03 11:35:19 +08:00
|
|
|
|
}
|