using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using TheIsland.Network;
using TheIsland.Models;
namespace TheIsland.UI
{
///
/// 事件日志面板 - 显示游戏事件历史
///
public class EventLog : MonoBehaviour
{
private static EventLog _instance;
public static EventLog Instance => _instance;
// 自动创建 EventLog 实例
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
private static void AutoCreate()
{
if (_instance == null)
{
var go = new GameObject("EventLog");
go.AddComponent();
DontDestroyOnLoad(go);
Debug.Log("[EventLog] 自动创建实例");
}
}
// UI 组件
private Canvas _canvas;
private GameObject _panel;
private ScrollRect _scrollRect;
private RectTransform _content;
private Button _toggleBtn;
private TextMeshProUGUI _toggleText;
private List _entries = new List();
private bool _visible = true;
private int _unread = 0;
private bool _ready = false;
private void Awake()
{
if (_instance != null && _instance != this)
{
Destroy(gameObject);
return;
}
_instance = this;
}
private void Start()
{
Debug.Log("[EventLog] Start - 开始初始化");
StartCoroutine(InitCoroutine());
}
private System.Collections.IEnumerator InitCoroutine()
{
// 等待一帧确保 Canvas 准备好
yield return null;
_canvas = FindAnyObjectByType