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.

61 lines
1.5 KiB

  1. /* ---------------------------------------
  2. * Author: Martin Pane (martintayx@gmail.com) (@tayx94)
  3. * Collaborators: Lars Aalbertsen (@Rockylars)
  4. * Project: Graphy - Ultimate Stats Monitor
  5. * Date: 05-Mar-18
  6. * Studio: Tayx
  7. *
  8. * This project is released under the MIT license.
  9. * Attribution is not required, but it is always welcomed!
  10. * -------------------------------------*/
  11. using UnityEngine;
  12. using UnityEngine.UI;
  13. using System.Collections;
  14. namespace Tayx.Graphy.CustomizationScene
  15. {
  16. [RequireComponent(typeof(Text))]
  17. public class UpdateTextWithSliderValue : MonoBehaviour
  18. {
  19. /* ----- TODO: ----------------------------
  20. * Check if we can seal this class.
  21. * Add summaries to the variables.
  22. * Add summaries to the functions.
  23. * Check if we can remove "using System.Collections;".
  24. * Check if we should add "private" to the Unity Callbacks.
  25. * --------------------------------------*/
  26. #region Variables -> Serialized Private
  27. [SerializeField] private Slider m_slider;
  28. #endregion
  29. #region Variables -> Private
  30. private Text m_text;
  31. #endregion
  32. #region Methods -> Unity Callbacks
  33. void Start()
  34. {
  35. m_text = GetComponent<Text>();
  36. m_slider.onValueChanged.AddListener(UpdateText);
  37. }
  38. #endregion
  39. #region Methods -> Private
  40. private void UpdateText(float value)
  41. {
  42. m_text.text = value.ToString();
  43. }
  44. #endregion
  45. }
  46. }