This commit is contained in:
CortexCore
2025-01-12 11:13:19 +08:00
parent 01e7e4e35e
commit 01b3d1be43
26 changed files with 387 additions and 336 deletions

View File

@@ -0,0 +1,69 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.TextCore.Text;
using UnityEngine.UIElements;
namespace BITKit.GameEditor
{
public class TMPFontCheck : EditorWindow
{
public static FontAsset CurrentFont;
[MenuItem("Tools/TextMeshPro Font Check")]
public static void ShowExample()
{
GetWindow<TMPFontCheck>().Show();
}
private void CreateGUI()
{
rootVisualElement.Clear();
var refreshButton = rootVisualElement.Create<Button>();
refreshButton.text = "刷新";
refreshButton.clicked += CreateGUI;
var mergeButton = rootVisualElement.Create<Button>();
mergeButton.text = "合并字符串";
var fontField = rootVisualElement.Create<ObjectField>();
fontField.objectType = typeof(FontAsset);
fontField.RegisterValueChangedCallback(x =>
{
CurrentFont = x.newValue as FontAsset;
});
fontField.SetValueWithoutNotify(CurrentFont);
var container = rootVisualElement.Create<VisualElement>();
container.style.flexDirection = FlexDirection.Column;
var label = container.Create<Label>();
label.style.unityFontDefinition = new FontDefinition()
{
fontAsset = CurrentFont
};
var textfield = container.Create<TextField>();
textfield.label = "Test Font";
textfield.multiline = true;
textfield.RegisterValueChangedCallback(x =>
{
label.text = x.newValue;
});
textfield.style.unityFontDefinition = label.style.unityFontDefinition;
mergeButton.clicked += () =>
{
textfield.value =new string(Regex.Replace(textfield.value, @"\s+", "").Distinct().ToArray());
};
}
}
}

View File

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