.vs
Assets
Images
Materials
Prefabs
Scenes
Scripts
TextMesh Pro
Documentation
Examples & Extras
Fonts
Materials
Prefabs
Resources
Scenes
Scripts
Benchmark01.cs
Benchmark01.cs.meta
Benchmark01_UGUI.cs
Benchmark01_UGUI.cs.meta
Benchmark02.cs
Benchmark02.cs.meta
Benchmark03.cs
Benchmark03.cs.meta
Benchmark04.cs
Benchmark04.cs.meta
CameraController.cs
CameraController.cs.meta
ChatController.cs
ChatController.cs.meta
DropdownSample.cs
DropdownSample.cs.meta
EnvMapAnimator.cs
EnvMapAnimator.cs.meta
ObjectSpin.cs
ObjectSpin.cs.meta
ShaderPropAnimator.cs
ShaderPropAnimator.cs.meta
SimpleScript.cs
SimpleScript.cs.meta
SkewTextExample.cs
SkewTextExample.cs.meta
TMP_DigitValidator.cs
TMP_DigitValidator.cs.meta
TMP_ExampleScript_01.cs
TMP_ExampleScript_01.cs.meta
TMP_FrameRateCounter.cs
TMP_FrameRateCounter.cs.meta
TMP_PhoneNumberValidator.cs
TMP_PhoneNumberValidator.cs.meta
TMP_TextEventCheck.cs
TMP_TextEventCheck.cs.meta
TMP_TextEventHandler.cs
TMP_TextEventHandler.cs.meta
TMP_TextInfoDebugTool.cs
TMP_TextInfoDebugTool.cs.meta
TMP_TextSelector_A.cs
TMP_TextSelector_A.cs.meta
TMP_TextSelector_B.cs
TMP_TextSelector_B.cs.meta
TMP_UiFrameRateCounter.cs
TMP_UiFrameRateCounter.cs.meta
TMPro_InstructionOverlay.cs
TMPro_InstructionOverlay.cs.meta
TeleType.cs
TeleType.cs.meta
TextConsoleSimulator.cs
TextConsoleSimulator.cs.meta
TextMeshProFloatingText.cs
TextMeshProFloatingText.cs.meta
TextMeshSpawner.cs
TextMeshSpawner.cs.meta
VertexColorCycler.cs
VertexColorCycler.cs.meta
VertexJitter.cs
VertexJitter.cs.meta
VertexShakeA.cs
VertexShakeA.cs.meta
VertexShakeB.cs
VertexShakeB.cs.meta
VertexZoom.cs
VertexZoom.cs.meta
WarpTextExample.cs
WarpTextExample.cs.meta
Sprites
Textures
Fonts.meta
Materials.meta
Prefabs.meta
Resources.meta
Scenes.meta
Scripts.meta
Sprites.meta
Textures.meta
Fonts
Resources
Shaders
Sprites
Documentation.meta
Examples & Extras.meta
Fonts.meta
Resources.meta
Shaders.meta
Sprites.meta
Images.meta
Materials.meta
Prefabs.meta
Scenes.meta
Scripts.meta
TextMesh Pro.meta
light.cs
light.cs.meta
Library
Logs
Packages
ProjectSettings
UserSettings
obj
.vsconfig
Assembly-CSharp.Player.csproj
Assembly-CSharp.csproj
TM1.sln
Unity.CollabProxy.Editor.csproj
Unity.EditorCoroutines.Editor.csproj
Unity.Performance.Profile-Analyzer.Editor.csproj
Unity.PlasticSCM.Editor.csproj
Unity.Rider.Editor.csproj
Unity.Settings.Editor.csproj
Unity.TestTools.CodeCoverage.Editor.OpenCover.Model.csproj
Unity.TestTools.CodeCoverage.Editor.OpenCover.Mono.Reflection.csproj
Unity.TestTools.CodeCoverage.Editor.csproj
Unity.TextMeshPro.Editor.csproj
Unity.TextMeshPro.Player.csproj
Unity.TextMeshPro.csproj
Unity.Timeline.Editor.csproj
Unity.Timeline.Player.csproj
Unity.Timeline.csproj
Unity.VSCode.Editor.csproj
Unity.VisualScripting.Core.Editor.csproj
Unity.VisualScripting.Core.Player.csproj
Unity.VisualScripting.Core.csproj
Unity.VisualScripting.Flow.Editor.csproj
Unity.VisualScripting.Flow.Player.csproj
Unity.VisualScripting.Flow.csproj
Unity.VisualScripting.SettingsProvider.Editor.csproj
Unity.VisualScripting.Shared.Editor.csproj
Unity.VisualScripting.State.Editor.csproj
Unity.VisualScripting.State.Player.csproj
Unity.VisualScripting.State.csproj
Unity.VisualStudio.Editor.csproj
UnityEditor.TestRunner.csproj
UnityEditor.UI.csproj
UnityEngine.TestRunner.Player.csproj
UnityEngine.TestRunner.csproj
UnityEngine.UI.Player.csproj
UnityEngine.UI.csproj
93 lines
3.6 KiB
C#
93 lines
3.6 KiB
C#
![]() |
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;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|