MeowmentDebugTool/Packages/com.bywaystudios.meowmentdebugtool/Runtime/ParametersModule.cs
2025-12-22 15:29:55 +08:00

133 lines
4.6 KiB
C#

using UnityEngine;
using TMPro;
using UnityEngine.UI;
namespace MeowmentDebugTool
{
/// <summary>
/// 参数查看模块 - 显示设备和系统信息
/// </summary>
public class ParametersModule : IDebugModule
{
#region
private GameObject parametersPage;
private TMP_Text deviceInfoText;
private TMP_Text systemInfoText;
private ScrollRect parametersScrollRect;
#endregion
#region
public ParametersModule(GameObject page, TMP_Text deviceInfo, TMP_Text systemInfo, ScrollRect scrollRect)
{
parametersPage = page;
deviceInfoText = deviceInfo;
systemInfoText = systemInfo;
parametersScrollRect = scrollRect;
}
#endregion
#region IDebugModule
public void Initialize()
{
Debug.Log("[ParametersModule] 初始化参数查看模块...");
UpdateDeviceInfo();
UpdateSystemInfo();
}
public GameObject GetPage()
{
return parametersPage;
}
public string GetModuleName()
{
return "参数";
}
#endregion
#region
/// <summary>
/// 复制设备信息到剪贴板
/// </summary>
public void CopyDeviceInfoToClipboard()
{
if (deviceInfoText != null)
{
GUIUtility.systemCopyBuffer = deviceInfoText.text;
Debug.Log("设备信息已复制到剪贴板");
}
}
/// <summary>
/// 复制系统信息到剪贴板
/// </summary>
public void CopySystemInfoToClipboard()
{
if (systemInfoText != null)
{
GUIUtility.systemCopyBuffer = systemInfoText.text;
Debug.Log("系统信息已复制到剪贴板");
}
}
/// <summary>
/// 刷新所有信息
/// </summary>
public void RefreshAllInfo()
{
UpdateDeviceInfo();
UpdateSystemInfo();
}
#endregion
#region
private void UpdateDeviceInfo()
{
if (deviceInfoText == null) return;
string info = "===== 设备信息 =====\n";
info += $"设备名称: {SystemInfo.deviceName}\n";
info += $"设备型号: {SystemInfo.deviceModel}\n";
info += $"设备类型: {SystemInfo.deviceType}\n";
info += $"操作系统: {SystemInfo.operatingSystem}\n";
info += $"处理器: {SystemInfo.processorType}\n";
info += $"处理器核心数: {SystemInfo.processorCount}\n";
info += $"系统内存: {SystemInfo.systemMemorySize} MB\n";
info += $"显存: {SystemInfo.graphicsMemorySize} MB\n";
info += $"设备标识符: {SystemInfo.deviceUniqueIdentifier}\n";
deviceInfoText.text = info;
}
private void UpdateSystemInfo()
{
if (systemInfoText == null) return;
string info = "===== 系统信息 =====\n";
info += $"Unity版本: {Application.unityVersion}\n";
info += $"平台: {Application.platform}\n";
info += $"产品名称: {Application.productName}\n";
info += $"公司名称: {Application.companyName}\n";
info += $"版本: {Application.version}\n";
info += $"数据路径: {Application.dataPath}\n";
info += $"持久化数据路径: {Application.persistentDataPath}\n";
info += $"临时缓存路径: {Application.temporaryCachePath}\n";
info += $"屏幕分辨率: {Screen.width} x {Screen.height} @ {Screen.currentResolution.refreshRateRatio.value:F2}Hz\n";
info += $"屏幕DPI: {Screen.dpi}\n";
info += $"是否全屏: {Screen.fullScreen}\n";
info += $"目标帧率: {Application.targetFrameRate}\n";
info += $"当前帧率: {(int)(1f / Time.smoothDeltaTime)}\n";
info += $"\n===== 图形信息 =====\n";
info += $"图形设备名称: {SystemInfo.graphicsDeviceName}\n";
info += $"图形设备供应商: {SystemInfo.graphicsDeviceVendor}\n";
info += $"图形设备类型: {SystemInfo.graphicsDeviceType}\n";
info += $"图形设备版本: {SystemInfo.graphicsDeviceVersion}\n";
info += $"着色器等级: {SystemInfo.graphicsShaderLevel}\n";
info += $"多线程渲染: {SystemInfo.graphicsMultiThreaded}\n";
systemInfoText.text = info;
}
#endregion
}
}