更改文件架构
This commit is contained in:
60
Packages/Common~/Scripts/UX/Debuger/UXDebuger.cs
Normal file
60
Packages/Common~/Scripts/UX/Debuger/UXDebuger.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using BITKit;
|
||||
using UnityEngine.UIElements;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using System.Linq;
|
||||
namespace BITKit.UX
|
||||
{
|
||||
public sealed class UXDebuger : UXElement<ListView>, IDebuger
|
||||
{
|
||||
List<string> texts = new();
|
||||
Dictionary<string, string> textDict = new();
|
||||
public override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
visualElement.itemsSource = texts;
|
||||
visualElement.makeItem = MakeItem;
|
||||
visualElement.bindItem = BindItem;
|
||||
}
|
||||
public void Log(string context)
|
||||
{
|
||||
texts.Add(context);
|
||||
}
|
||||
public async void Log(string title, string context)
|
||||
{
|
||||
//await UniTask.SwitchToThreadPool();
|
||||
textDict.Insert(title, context);
|
||||
texts.Clear();
|
||||
texts.AddRange(textDict.Select(x => $"{x.Key}:{x.Value}"));
|
||||
try
|
||||
{
|
||||
await UniTask.SwitchToMainThread(BITApp.CancellationTokenSource.Token);
|
||||
}
|
||||
catch (System.OperationCanceledException)
|
||||
{
|
||||
|
||||
}
|
||||
catch (System.Exception)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
VisualElement MakeItem()
|
||||
{
|
||||
return new Label();
|
||||
}
|
||||
void BindItem(VisualElement element, int index)
|
||||
{
|
||||
var label = element as Label;
|
||||
label.text = texts[index];
|
||||
}
|
||||
void Awake()
|
||||
{
|
||||
DI.Register<IDebuger>(this);
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/UX/Debuger/UXDebuger.cs.meta
Normal file
11
Packages/Common~/Scripts/UX/Debuger/UXDebuger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5a22846b573d5c4685160aed721d514
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user