using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class loadingbar : MonoBehaviour { private RectTransform rectComponent; private Image imageComp; public float speed = 0.0f; // Use this for initialization void Start () { rectComponent = GetComponent(); imageComp = rectComponent.GetComponent(); imageComp.fillAmount = 0.0f; } void Update() { if (imageComp.fillAmount != 1f) { imageComp.fillAmount = imageComp.fillAmount + Time.deltaTime * speed; } else { imageComp.fillAmount = 0.0f; } } }