(client) feat:实现摄像机跟踪与移动,实现任意位置生成实体,实现更安全的资源加载方式(指定unity内部加载资源) (#42)

Co-authored-by: zzdxxz <2079238449@qq.com>
Co-committed-by: zzdxxz <2079238449@qq.com>
This commit is contained in:
2025-08-07 16:44:43 +08:00
committed by TheRedApricot
parent 82dc89c890
commit 670f778eee
143 changed files with 9706 additions and 8122 deletions

View File

@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace Logging
{
public static class LogCapturer
{
// 日志条目结构
public struct LogEntry
{
public DateTime Timestamp;
public LogType Type;
public string Message;
public string StackTrace;
public override string ToString() =>
$"[{Timestamp:HH:mm:ss}] [{Type}] {Message}" +
(Type == LogType.Exception ? $"\n{StackTrace}" : "");
}
private static readonly Queue<LogEntry> _logs = new Queue<LogEntry>();
private static readonly object _lock = new object(); // 线程锁
private static int _maxLogs = 1000; // 默认容量
// 最大日志容量属性
public static int MaxLogs
{
get => _maxLogs;
set {
lock (_lock) {
_maxLogs = Mathf.Max(value, 1); // 最小值为1
TrimExcess();
}
}
}
static LogCapturer()
{
// 注册全局日志回调
Application.logMessageReceivedThreaded += HandleLog;
}
// 日志处理回调
private static void HandleLog(string message, string stackTrace, LogType type)
{
lock (_lock)
{
var entry = new LogEntry
{
Timestamp = DateTime.Now,
Type = type,
Message = message,
StackTrace = stackTrace
};
_logs.Enqueue(entry);
TrimExcess();
}
}
// 日志队列修剪
private static void TrimExcess()
{
while (_logs.Count > _maxLogs)
{
_logs.Dequeue();
}
}
// 获取当前所有日志(倒序:最新在前)
public static List<LogEntry> GetLogs(bool reverseOrder = true)
{
lock (_lock)
{
var list = new List<LogEntry>(_logs);
if (reverseOrder) list.Reverse();
return list;
}
}
// 清空日志
public static void Clear()
{
lock (_lock)
{
_logs.Clear();
}
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9095bd039dd74398a68ce9b93da74df0
timeCreated: 1753456559