ProgressBar script for Unity (C#)


SUBMITTED BY: KaiMolan

DATE: Aug. 21, 2015, 9:03 p.m.

FORMAT: C#

SIZE: 1.2 kB

HITS: 639

  1. /*
  2. * If you like my work, and found it useful
  3. * Please donate
  4. * Bitcoin Address: 1LdyAQHXdFVqzGzah45sGKhsQ8wDE6jyci
  5. * Good luck and enjoy.
  6. *
  7. */
  8. using UnityEngine;
  9. namespace Assets.Scripts
  10. {
  11. public class ProgressBar
  12. {
  13. private readonly GameObject _gameObject;
  14. private float _value;
  15. public Color BackGroundColor { get; set; }
  16. public Color ForeGroundColor { get; set; }
  17. public float MaxValue { get; set; }
  18. public Vector2 Position { get; set; }
  19. public Vector2 Size { get; set; }
  20. public bool IsEnabled { get { return _gameObject.activeSelf; } set{_gameObject.SetActive(value);}}
  21. public bool IsVertical { get; set; }
  22. public float Value
  23. {
  24. get { return _value; }
  25. set { _value = Mathf.Clamp(value, 0, MaxValue); }
  26. }
  27. public ProgressBar()
  28. {
  29. _gameObject = new GameObject();
  30. _gameObject.AddComponent<ProgressBarRenderer>().Init(this);
  31. }
  32. public void Destroy()
  33. {
  34. Object.Destroy(_gameObject);
  35. }
  36. }
  37. }

comments powered by Disqus