I am new to unity and am trying to create a simple moving progress bar. I have created the progress bar that moves up and down by vertical filling. However, I want to add a black line over the moving filled area (so it matches the border, see images). Is there an easy way to make the black horizontal line move with the other object as it fills (right now the black line is just a stationary object).
@AnnaVicVic Attach this script to the moving line and make moving line child of the surface (the surface will be a fill image)
public class MoveableLine : MonoBehaviour
public Image fillImage;
public float rectHeight
public float incrementFactor;
void Update ()
var fillImageRect = fillImage.GetComponent<RectTransform>();
rectHeight = fillImageRect.rect.height/2;
incrementFactor = (fillImage.fillAmount * (fillImageRect.rect.height))- fillImageRect.rect.height/2;
this.GetComponent<RectTransform>().localPosition=new Vector3(0, incrementFactor, 0);
I also want to know more about it. Thank you!