Basically I have a code that whenever an object is dropped into a slot the count increments by 1.
I have 5 pieces of the “puzzle” that are dropped into corresponding slots, but the count goes to the 6th element (number 5 in this case) but it doesn’t run the else statement.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class RPB : MonoBehaviour {
public Transform LoadingBar;
public Transform TextIndicator;
public Transform TextLoading;
[SerializeField] public int currentAmount;
void Start(){
}
void Update(){
StartCoroutine(CountThis());
}
IEnumerator CountThis() {
Text output = TextIndicator.GetComponent<Text>();
currentAmount = GameObject.Find("Canvas").GetComponent<Bones> ().count;
if (currentAmount < 5) {
output.text = ((int)currentAmount).ToString () + "/5";
TextLoading.gameObject.SetActive (true);
} else {
Debug.Log ("GO GET IT");
TextLoading.gameObject.SetActive (false);
output.text = "GGZ BOIZ";
yield break;
}
LoadingBar.GetComponent<Image>().fillAmount = currentAmount * 0.2f ;
}
}