This commit is contained in:
2025-11-13 17:40:28 +08:00
parent 962ab49609
commit 10156da245
5503 changed files with 805282 additions and 0 deletions

View File

@@ -0,0 +1,124 @@
/*******************************************************************************
Copyright © 2015-2022 PICO Technology Co., Ltd.All rights reserved.
NOTICEAll information contained herein is, and remains the property of
PICO Technology Co., Ltd. The intellectual and technical concepts
contained herein are proprietary to PICO Technology Co., Ltd. and may be
covered by patents, patents in process, and are protected by trade secret or
copyright law. Dissemination of this information or reproduction of this
material is strictly forbidden unless prior written permission is obtained from
PICO Technology Co., Ltd.
*******************************************************************************/
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
namespace Unity.XR.PXR.Debugger
{
public class PXR_LogManager : MonoBehaviour, IPXR_PanelManager
{
public List<GameObject> infoList = new();
public List<GameObject> warningList = new();
public List<GameObject> errorList = new();
public GameObject errorMessage;
public GameObject warningMessage;
public GameObject infoMessage;
public Text infoText;
public Text warningText;
public Text errorText;
public Transform messageContainer;
private int ListCount => infoList.Count + warningList.Count + errorList.Count;
private void AddMessage(string title, string content, LogType type)
{
switch (type)
{
case LogType.Error:
CreateMessage(title, content, type, errorList, errorMessage);
break;
case LogType.Assert:
break;
case LogType.Warning:
CreateMessage(title, content, type, warningList, warningMessage);
break;
case LogType.Log:
CreateMessage(title, content, type, infoList, infoMessage);
break;
case LogType.Exception:
break;
}
RecaculateLogCount();
}
private void CreateMessage(string title, string content, in LogType type, in List<GameObject> list, in GameObject template)
{
var msg = Instantiate(template, messageContainer).GetComponent<PXR_MessageController>();
msg.Init(title, content);
list.Add(msg.gameObject);
}
private void RecaculateLogCount()
{
infoText.text = infoList.Count.ToString();
warningText.text = warningList.Count.ToString();
errorText.text = errorList.Count.ToString();
}
public void FilterLogs(LogType type, bool isFilter)
{
switch (type)
{
case LogType.Error:
ToggleLogs(errorList, isFilter);
break;
case LogType.Assert:
break;
case LogType.Warning:
ToggleLogs(warningList, isFilter);
break;
case LogType.Log:
ToggleLogs(infoList, isFilter);
break;
case LogType.Exception:
break;
}
}
private void ToggleLogs(in List<GameObject> list, bool status)
{
foreach (var item in list)
{
item.SetActive(status);
}
}
void Start()
{
Application.logMessageReceived += OnLogMessageReceived;
}
private void OnLogMessageReceived(string logString, string stackTrace, LogType type)
{
if (PXR_UIController.Instance.config.maxInfoCount > ListCount)
{
AddMessage(logString, stackTrace, type);
}
}
void OnEnable()
{
foreach (var item in infoList)
{
item.GetComponent<PXR_MessageController>().Reset();
}
foreach (var item in warningList)
{
item.GetComponent<PXR_MessageController>().Reset();
}
foreach (var item in errorList)
{
item.GetComponent<PXR_MessageController>().Reset();
}
}
public void Init(){
}
void OnDestroy()
{
Application.logMessageReceived -= OnLogMessageReceived;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 37649a96b60c841e08f9e20ab7f59dfd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,59 @@
/*******************************************************************************
Copyright © 2015-2022 PICO Technology Co., Ltd.All rights reserved.
NOTICEAll information contained herein is, and remains the property of
PICO Technology Co., Ltd. The intellectual and technical concepts
contained herein are proprietary to PICO Technology Co., Ltd. and may be
covered by patents, patents in process, and are protected by trade secret or
copyright law. Dissemination of this information or reproduction of this
material is strictly forbidden unless prior written permission is obtained from
PICO Technology Co., Ltd.
*******************************************************************************/
using UnityEngine;
using UnityEngine.UI;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
namespace Unity.XR.PXR.Debugger
{
public class PXR_MessageController : MonoBehaviour
{
// Start is called before the first frame update
public Text title;
public Text content;
private readonly string widthMark = "------------------------------------------------------------------";
private readonly int maxLength = 47;
public void Init(string title, string content)
{
string timestamp = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
string finalTitle = $"{timestamp}: {title}";
TextGenerator generator = new();
var settings = this.title.GetGenerationSettings(this.title.gameObject.GetComponent<RectTransform>().rect.size);
var targetWidth = generator.GetPreferredWidth(widthMark, settings);
var currentWidth = generator.GetPreferredWidth(finalTitle, settings);
if (targetWidth < currentWidth)
{
finalTitle = title[..(maxLength - 3)];
currentWidth = generator.GetPreferredWidth(finalTitle, settings);
while (targetWidth < currentWidth)
{
finalTitle = title[..(title.Length - 1)];
currentWidth = generator.GetPreferredWidth(finalTitle, settings);
}
finalTitle += "...";
}
this.title.text = finalTitle;
this.content.text = $"{title}\n{content}";
Reset();
}
public void Reset()
{
LayoutRebuilder.ForceRebuildLayoutImmediate(gameObject.GetComponent<RectTransform>());
}
public void ToggleContent()
{
content.gameObject.SetActive(!content.gameObject.activeSelf);
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 291fd7bf1abf04b508dbc7b5609dfe15
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: