I created a function that will run until an images fillamount is at 0. However when I call this function from another class the unity editor completing freezes. I cant even stop pause play mode.
The class that calls the cooldown function.
Cooldown cooldown;
cooldown = gameObject.GetComponentInChildren<Cooldown>();//Sets cooldown to have the same values as the prefab.
public void gatherCooldown()
{
cooldown.resourceCooldown();
}
Cooldown Class
public class Cooldown : MonoBehaviour
{
public Image imageCooldown;
public float cooldown = 5;
public bool isCooldown
public void resourceCooldown()
{
while (imageCooldown.fillAmount >= 0)
{
imageCooldown.fillAmount -= 1 / cooldown * Time.deltaTime;
}
}
}