uGUITextUpdater.cs 501 B

12345678910111213141516171819202122
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. public class uGUITextUpdater : MonoBehaviour
  5. {
  6. public void OnUpdateText(float value)
  7. {
  8. this.m_TextObject.text = this.m_StringBeforeMessage + string.Format("{0:#0.###}", value) + this.m_StringAfterMessage;
  9. }
  10. [SerializeField]
  11. [TextArea(1, 1)]
  12. private string m_StringBeforeMessage = string.Empty;
  13. [SerializeField]
  14. [TextArea(1, 1)]
  15. private string m_StringAfterMessage = string.Empty;
  16. [SerializeField]
  17. private Text m_TextObject;
  18. }