2d0aaa98aa
- 重写 PageController.cs,为所有按钮回调添加完整 Debug.Log - 自动修复 _btnFixationBack:未赋值时自动查找 FixationPanel/BtnBack - 自动修复 _btnExperimentBack:未赋值时自动查找 ExperimentPanel/Navbar/BtnBack - 删除失效的 Canvas 根级冗余 BtnFixationBack - 添加 3D 角色模型资源(man/woman 模型、动画、TextMesh Pro) - 添加 ExperimentPanel UI 资源和 TrainingBackground 素材 测试方法:进入 Play 模式,查看 Console 以验证每个按钮的绑定状态和点击回调是否正常触发。
93 lines
3.6 KiB
C#
Executable File
93 lines
3.6 KiB
C#
Executable File
using UnityEngine;
|
|
using System.Collections;
|
|
using UnityEngine.TextCore.LowLevel;
|
|
|
|
|
|
namespace TMPro.Examples
|
|
{
|
|
|
|
public class Benchmark03 : MonoBehaviour
|
|
{
|
|
public enum BenchmarkType { TMP_SDF_MOBILE = 0, TMP_SDF__MOBILE_SSD = 1, TMP_SDF = 2, TMP_BITMAP_MOBILE = 3, TEXTMESH_BITMAP = 4 }
|
|
|
|
public int NumberOfSamples = 100;
|
|
public BenchmarkType Benchmark;
|
|
|
|
public Font SourceFont;
|
|
|
|
|
|
void Awake()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
void Start()
|
|
{
|
|
TMP_FontAsset fontAsset = null;
|
|
|
|
// Create Dynamic Font Asset for the given font file.
|
|
switch (Benchmark)
|
|
{
|
|
case BenchmarkType.TMP_SDF_MOBILE:
|
|
fontAsset = TMP_FontAsset.CreateFontAsset(SourceFont, 90, 9, GlyphRenderMode.SDFAA, 256, 256, AtlasPopulationMode.Dynamic);
|
|
break;
|
|
case BenchmarkType.TMP_SDF__MOBILE_SSD:
|
|
fontAsset = TMP_FontAsset.CreateFontAsset(SourceFont, 90, 9, GlyphRenderMode.SDFAA, 256, 256, AtlasPopulationMode.Dynamic);
|
|
fontAsset.material.shader = Shader.Find("TextMeshPro/Mobile/Distance Field SSD");
|
|
break;
|
|
case BenchmarkType.TMP_SDF:
|
|
fontAsset = TMP_FontAsset.CreateFontAsset(SourceFont, 90, 9, GlyphRenderMode.SDFAA, 256, 256, AtlasPopulationMode.Dynamic);
|
|
fontAsset.material.shader = Shader.Find("TextMeshPro/Distance Field");
|
|
break;
|
|
case BenchmarkType.TMP_BITMAP_MOBILE:
|
|
fontAsset = TMP_FontAsset.CreateFontAsset(SourceFont, 90, 9, GlyphRenderMode.SMOOTH, 256, 256, AtlasPopulationMode.Dynamic);
|
|
break;
|
|
}
|
|
|
|
for (int i = 0; i < NumberOfSamples; i++)
|
|
{
|
|
switch (Benchmark)
|
|
{
|
|
case BenchmarkType.TMP_SDF_MOBILE:
|
|
case BenchmarkType.TMP_SDF__MOBILE_SSD:
|
|
case BenchmarkType.TMP_SDF:
|
|
case BenchmarkType.TMP_BITMAP_MOBILE:
|
|
{
|
|
GameObject go = new GameObject();
|
|
go.transform.position = new Vector3(0, 1.2f, 0);
|
|
|
|
TextMeshPro textComponent = go.AddComponent<TextMeshPro>();
|
|
textComponent.font = fontAsset;
|
|
textComponent.fontSize = 128;
|
|
textComponent.text = "@";
|
|
textComponent.alignment = TextAlignmentOptions.Center;
|
|
textComponent.color = new Color32(255, 255, 0, 255);
|
|
|
|
if (Benchmark == BenchmarkType.TMP_BITMAP_MOBILE)
|
|
textComponent.fontSize = 132;
|
|
|
|
}
|
|
break;
|
|
case BenchmarkType.TEXTMESH_BITMAP:
|
|
{
|
|
GameObject go = new GameObject();
|
|
go.transform.position = new Vector3(0, 1.2f, 0);
|
|
|
|
TextMesh textMesh = go.AddComponent<TextMesh>();
|
|
textMesh.GetComponent<Renderer>().sharedMaterial = SourceFont.material;
|
|
textMesh.font = SourceFont;
|
|
textMesh.anchor = TextAnchor.MiddleCenter;
|
|
textMesh.fontSize = 130;
|
|
|
|
textMesh.color = new Color32(255, 255, 0, 255);
|
|
textMesh.text = "@";
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|