-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoadingBar.cs
30 lines (28 loc) · 905 Bytes
/
LoadingBar.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class LoadingBar : MonoBehaviour {
public Transform Loadingbar;
public Transform TextIndicator;
public Transform TextLoading;
[SerializeField]
private float currentAmount;
[SerializeField]
private float speed;
// Update is called once per frame
void Update () {
if (currentAmount < 100)
{
currentAmount += speed * Time.deltaTime;
TextIndicator.GetComponent<Text>().text = ((int)currentAmount).ToString() + "%";
TextLoading.gameObject.SetActive(true);
}
else
{
TextLoading.gameObject.SetActive(false);
TextIndicator.GetComponent<Text>().text = "Done!";
}
Loadingbar.GetComponent<Image>().fillAmount = currentAmount / 100;
}
}