public void Refresh() { rockProps = ore.GetComponent <OreProperties>(); for (int i = 0; i < addButtons.Length; i++) { RefreshButton(addButtons[i], i); } }
public void RefreshButton(Button button, int slot) { rockProps = ore.GetComponent <OreProperties>(); if (!rockProps.hasSlot[slot]) { addButtons[slot].interactable = true; addButtons[slot].animator.enabled = false; addButtons[slot].image.sprite = origButtonSprite; } else { addButtons[slot].interactable = false; addButtons[slot].animator.enabled = true; } }
private void OnGUI() { var rockImage = transform.GetChild(0).gameObject; var image = rockImage.GetComponent <Image>(); if (ore != null) { foreach (Button button in addButtons) { button.image.enabled = true; } image.enabled = true; rockProps = ore.GetComponent <OreProperties>(); float rockPercentage = (float)rockProps.Ore / rockProps.originalOre; if (rockPercentage < .25f) { image.sprite = rockStates[3]; } else if (rockPercentage < .50f) { image.sprite = rockStates[2]; } else if (rockPercentage < .75f) { image.sprite = rockStates[1]; } else { image.sprite = rockStates[0]; } } else { image.enabled = false; foreach (Button button in addButtons) { button.interactable = false; button.image.enabled = false; } } }