unity3d - Change Image.fillAmount -
i have image acting health bar, , want give cistume value more 1:
public image healthbar; // use initialization void start () { float health = 4; healthbar.fillamount = health; debug.log (gameobject + ""+ healthbar.fillamount); }
problem no matter value give health, fillamount goes 1. there way make higher ?
fillamount value of 0-1, @ 1 full image being shown. there no behavior yet numbers on 1.
you change width of image based on maximum health , calculate percentage needs filled.
healthbar.recttransform.rect.width = maxhealth * healthbarwidth; healthbar.fillamount = health / maxhealth;
if don't want 1 bar, multiple images hearts still filled partially, might able tiled image automatically truncates @ edges.
Comments
Post a Comment