I have a game in which I need a progress bar to display the current amount of objects that are placed in the correct slots. I have this script but it loads it as full amount of 5. Please help if possible. Thanks
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class RPB : MonoBehaviour {
public Transform LoadingBar;
public Transform TextIndicator;
public Transform TextLoading;
[SerializeField] private float currentAmount;
[SerializeField] private int count = 0;
void Start(){
currentAmount = count;
CountThis();
}
void Update(){
}
void CountThis() {
for (int i = 0; i < 6; i = i+1) {
Debug.Log (currentAmount);
count = i;
currentAmount = count;
}if (currentAmount < 6) {
TextIndicator.GetComponent<Text> ().text = ((int)currentAmount).ToString () + "/5";
TextLoading.gameObject.SetActive (true);
}else {
TextLoading.gameObject.SetActive(false);
TextIndicator.GetComponent<Text>().text = "DONE!";
Debug.Log(currentAmount);
}
LoadingBar.GetComponent<Image> ().fillAmount = currentAmount / 5 ;
}
}