You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.8 KiB

  1. using UnityEngine;
  2. using System.Collections;
  3. namespace TMPro.Examples
  4. {
  5. public class SimpleScript : MonoBehaviour
  6. {
  7. private TextMeshPro m_textMeshPro;
  8. //private TMP_FontAsset m_FontAsset;
  9. private const string label = "The <#0050FF>count is: </color>{0:2}";
  10. private float m_frame;
  11. void Start()
  12. {
  13. // Add new TextMesh Pro Component
  14. m_textMeshPro = gameObject.AddComponent<TextMeshPro>();
  15. m_textMeshPro.autoSizeTextContainer = true;
  16. // Load the Font Asset to be used.
  17. //m_FontAsset = Resources.Load("Fonts & Materials/LiberationSans SDF", typeof(TMP_FontAsset)) as TMP_FontAsset;
  18. //m_textMeshPro.font = m_FontAsset;
  19. // Assign Material to TextMesh Pro Component
  20. //m_textMeshPro.fontSharedMaterial = Resources.Load("Fonts & Materials/LiberationSans SDF - Bevel", typeof(Material)) as Material;
  21. //m_textMeshPro.fontSharedMaterial.EnableKeyword("BEVEL_ON");
  22. // Set various font settings.
  23. m_textMeshPro.fontSize = 48;
  24. m_textMeshPro.alignment = TextAlignmentOptions.Center;
  25. //m_textMeshPro.anchorDampening = true; // Has been deprecated but under consideration for re-implementation.
  26. //m_textMeshPro.enableAutoSizing = true;
  27. //m_textMeshPro.characterSpacing = 0.2f;
  28. //m_textMeshPro.wordSpacing = 0.1f;
  29. //m_textMeshPro.enableCulling = true;
  30. m_textMeshPro.enableWordWrapping = false;
  31. //textMeshPro.fontColor = new Color32(255, 255, 255, 255);
  32. }
  33. void Update()
  34. {
  35. m_textMeshPro.SetText(label, m_frame % 1000);
  36. m_frame += 1 * Time.deltaTime;
  37. }
  38. }
  39. }