diff options
| author | dereelatwit <54997325+dereelatwit@users.noreply.github.com> | 2023-08-03 14:05:08 -0400 |
|---|---|---|
| committer | dereelatwit <54997325+dereelatwit@users.noreply.github.com> | 2023-08-03 14:05:08 -0400 |
| commit | b8aa2e0935f309b112648f0352f35f5f33da946b (patch) | |
| tree | 9121ae1a65e483dddba8367cbbdd4991abfb3e26 /Pathfinding Visualizer/Assets/TextMesh Pro/Examples & Extras/Scripts/Benchmark01_UGUI.cs | |
| parent | 374125ba34e0366afb062578906877cfdf229bb9 (diff) | |
started implementing UI
Diffstat (limited to 'Pathfinding Visualizer/Assets/TextMesh Pro/Examples & Extras/Scripts/Benchmark01_UGUI.cs')
| -rw-r--r-- | Pathfinding Visualizer/Assets/TextMesh Pro/Examples & Extras/Scripts/Benchmark01_UGUI.cs | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/Pathfinding Visualizer/Assets/TextMesh Pro/Examples & Extras/Scripts/Benchmark01_UGUI.cs b/Pathfinding Visualizer/Assets/TextMesh Pro/Examples & Extras/Scripts/Benchmark01_UGUI.cs new file mode 100644 index 0000000..38f4a27 --- /dev/null +++ b/Pathfinding Visualizer/Assets/TextMesh Pro/Examples & Extras/Scripts/Benchmark01_UGUI.cs @@ -0,0 +1,135 @@ +using UnityEngine; +using System.Collections; +using UnityEngine.UI; + + +namespace TMPro.Examples +{ + + public class Benchmark01_UGUI : MonoBehaviour + { + + public int BenchmarkType = 0; + + public Canvas canvas; + public TMP_FontAsset TMProFont; + public Font TextMeshFont; + + private TextMeshProUGUI m_textMeshPro; + //private TextContainer m_textContainer; + private Text m_textMesh; + + private const string label01 = "The <#0050FF>count is: </color>"; + private const string label02 = "The <color=#0050FF>count is: </color>"; + + //private const string label01 = "TextMesh <#0050FF>Pro!</color> The count is: {0}"; + //private const string label02 = "Text Mesh<color=#0050FF> The count is: </color>"; + + //private string m_string; + //private int m_frame; + + private Material m_material01; + private Material m_material02; + + + + IEnumerator Start() + { + + + + if (BenchmarkType == 0) // TextMesh Pro Component + { + m_textMeshPro = gameObject.AddComponent<TextMeshProUGUI>(); + //m_textContainer = GetComponent<TextContainer>(); + + + //m_textMeshPro.anchorDampening = true; + + if (TMProFont != null) + m_textMeshPro.font = TMProFont; + + //m_textMeshPro.font = Resources.Load("Fonts & Materials/Anton SDF", typeof(TextMeshProFont)) as TextMeshProFont; // Make sure the Anton SDF exists before calling this... + //m_textMeshPro.fontSharedMaterial = Resources.Load("Fonts & Materials/Anton SDF", typeof(Material)) as Material; // Same as above make sure this material exists. + + m_textMeshPro.fontSize = 48; + m_textMeshPro.alignment = TextAlignmentOptions.Center; + //m_textMeshPro.anchor = AnchorPositions.Center; + m_textMeshPro.extraPadding = true; + //m_textMeshPro.outlineWidth = 0.25f; + //m_textMeshPro.fontSharedMaterial.SetFloat("_OutlineWidth", 0.2f); + //m_textMeshPro.fontSharedMaterial.EnableKeyword("UNDERLAY_ON"); + //m_textMeshPro.lineJustification = LineJustificationTypes.Center; + //m_textMeshPro.enableWordWrapping = true; + //m_textMeshPro.lineLength = 60; + //m_textMeshPro.characterSpacing = 0.2f; + //m_textMeshPro.fontColor = new Color32(255, 255, 255, 255); + + m_material01 = m_textMeshPro.font.material; + m_material02 = Resources.Load<Material>("Fonts & Materials/LiberationSans SDF - BEVEL"); // Make sure the LiberationSans SDF exists before calling this... + + + } + else if (BenchmarkType == 1) // TextMesh + { + m_textMesh = gameObject.AddComponent<Text>(); + + if (TextMeshFont != null) + { + m_textMesh.font = TextMeshFont; + //m_textMesh.renderer.sharedMaterial = m_textMesh.font.material; + } + else + { + //m_textMesh.font = Resources.Load("Fonts/ARIAL", typeof(Font)) as Font; + //m_textMesh.renderer.sharedMaterial = m_textMesh.font.material; + } + + m_textMesh.fontSize = 48; + m_textMesh.alignment = TextAnchor.MiddleCenter; + + //m_textMesh.color = new Color32(255, 255, 0, 255); + } + + + + for (int i = 0; i <= 1000000; i++) + { + if (BenchmarkType == 0) + { + m_textMeshPro.text = label01 + (i % 1000); + if (i % 1000 == 999) + m_textMeshPro.fontSharedMaterial = m_textMeshPro.fontSharedMaterial == m_material01 ? m_textMeshPro.fontSharedMaterial = m_material02 : m_textMeshPro.fontSharedMaterial = m_material01; + + + + } + else if (BenchmarkType == 1) + m_textMesh.text = label02 + (i % 1000).ToString(); + + yield return null; + } + + + yield return null; + } + + + /* + void Update() + { + if (BenchmarkType == 0) + { + m_textMeshPro.text = (m_frame % 1000).ToString(); + } + else if (BenchmarkType == 1) + { + m_textMesh.text = (m_frame % 1000).ToString(); + } + + m_frame += 1; + } + */ + } + +} |
