Guest User

Untitled

a guest
Mar 18th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class RadicalCircle : MonoBehaviour {
  6.  
  7.  
  8. // Color of the Circle
  9. [SerializeField]
  10. public Color color = Color.blue;
  11.  
  12. // reference to the material
  13. private Material mRadicalMaterial = null;
  14.  
  15. void Awake()
  16. {
  17. SpriteRenderer sprite = gameObject.GetComponentInChildren<SpriteRenderer>();
  18. if(sprite !=null) {
  19. mRadicalMaterial = sprite.material;
  20. }
  21.  
  22. UpdateColor();
  23. }
  24.  
  25. void Start()
  26. {
  27.  
  28. }
  29.  
  30. // Percent of the Circle (0 - 100)
  31. private float mPercent = 0;
  32. public float Percent {
  33. get {
  34. return mPercent;
  35. }
  36.  
  37. set {
  38. // value correction
  39. mPercent = Mathf.Clamp(value, 0, 100);
  40. if(mRadicalMaterial != null) {
  41. mRadicalMaterial.SetFloat("_RadialBarPercent", -mPercent / 100);
  42. }
  43. }
  44. }
  45.  
  46.  
  47. public void UpdateColor() {
  48. if(mRadicalMaterial != null) {
  49. mRadicalMaterial.SetColor("_Color", color);
  50. }
  51. }
  52.  
  53. // Update is called once per frame
  54. void Update () {
  55.  
  56. }
  57. }
Add Comment
Please, Sign In to add comment