1
This commit is contained in:
69
Src/UnityEditor/TMPFontCheckWindow.cs
Normal file
69
Src/UnityEditor/TMPFontCheckWindow.cs
Normal 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());
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
11
Src/UnityEditor/TMPFontCheckWindow.cs.meta
Normal file
11
Src/UnityEditor/TMPFontCheckWindow.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 707aad4d7f4d82c46866eb25231c2388
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user