The question is answered, right answer was accepted
Fill Amount not doing anything.
Hi, I'm having a weird issue with the fill amount option, so I'm out of suggestions of what could be wrong.
public Image HealthBar;
public Image HealthBarBG;
public void SetHealthPercent(float fraction)
{
HealthBar.fillAmount = 0.5f;
//HealthBar.fillAmount = fraction;
Debug.Log("New Health fill amount = " + HealthBar.fillAmount);
if (fraction < 1)
this.transform.gameObject.SetActive(true);
else
this.transform.gameObject.SetActive(false);
}
That's the code I'm using and even with the forced 0.5 value, nothing happens. It stay at fully filled.
I've seen the suggestion to change image type to filled, which I tried (even though I need to go into debug editing to get at that setting), but that had no effect either. I've double checked while running that the fill amount is getting the setting and not being instantly reverted or something, and it stays, but doesn't seem to do anything. I'm out of ideas on what could be wrong here.
I don't have any issue with your current script.
$$anonymous$$y image is set up as follow:
And **yes*, the fillAmount
value has effect only on images set up as Filled
UGH... it seems the tutorial I was sorta following set everything up... then dropped in an additional thing later which I completely missed, which is the need to specify an sprite. And now it works! Hurrah... I guess... wasted so much time last night trying everything I could think of to figure this out. Oh well, my own fault for skipping around the tutorial.
Anyway, thanks Hellium. At the very least you clued me to trying that with the screen cap.
Follow this Question
Related Questions
Raw Image trigger 0 Answers
Unable to find image effects in unity 5.6.1(f1) 0 Answers
When i clicked on any particular object in my GAME then only the background should get blurred? 0 Answers
Filling sprite with alpha in specific direction 0 Answers
Black Hole Image Effect warping objects in front of the black hole. How can I fix this? 0 Answers