| | 1 | | using System.Collections; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using UnityEngine; |
| | 4 | | using UnityEngine.UI; |
| | 5 | |
|
| | 6 | | public class UILoadingSpinner : MonoBehaviour |
| | 7 | | { |
| | 8 | | Material _material; |
| | 9 | | public Image img; |
| | 10 | |
|
| | 11 | | public Color color; |
| | 12 | | public float head; |
| | 13 | | public float tail; |
| | 14 | |
|
| | 15 | | void Start() |
| | 16 | | { |
| 82 | 17 | | GetMaterial(); |
| 82 | 18 | | } |
| | 19 | |
|
| | 20 | | void GetMaterial() |
| | 21 | | { |
| 82 | 22 | | if (img.maskable) |
| | 23 | | { |
| 82 | 24 | | _material = img.materialForRendering; |
| 82 | 25 | | } |
| | 26 | | else |
| | 27 | | { |
| 0 | 28 | | _material = new Material(img.material); |
| 0 | 29 | | img.material = _material; |
| | 30 | | } |
| 0 | 31 | | } |
| | 32 | |
|
| | 33 | | void Update() |
| | 34 | | { |
| 6 | 35 | | SetValues(); |
| 6 | 36 | | } |
| | 37 | |
|
| | 38 | |
|
| | 39 | | public void SetValues() |
| | 40 | | { |
| 6 | 41 | | if(_material) |
| | 42 | | { |
| 6 | 43 | | _material.SetColor("_color01", color); |
| 6 | 44 | | _material.SetFloat("_fillHead", head); |
| 6 | 45 | | _material.SetFloat("_fillTail", tail); |
| 6 | 46 | | } |
| | 47 | | else |
| | 48 | | { |
| 0 | 49 | | GetMaterial(); |
| 0 | 50 | | SetValues(); |
| | 51 | | } |
| | 52 | |
|
| 0 | 53 | | } |
| | 54 | | } |