简体   繁体   中英

Unity2D - fill amount edge indicator

im working on racing game and there is a panel that shows how far the player has traveled. i want to place an icon at the egde of the horizontal fill amount image to indicate the current position on the panel.. this calculate the fill amount

public void Update() {
    progress = playerTransform.position.x / totaldistance;
    loading.fillAmount = progress;
}

how do i place an image on the edge of the horizontal fill amount image?

Thanks in advance

float width = lProgress.GetComponent<RectTransform>().rect.width;
Vector3 tempV = indicator.GetComponent<RectTransform>().anchoredPosition;
tempV.x = -width/2;
tempV.x += width * lProgress.fillAmount;
indicator.GetComponent<RectTransform>().anchoredPosition = tempV;

I know this is an old question, I found the solution today. Thought it might be helpful to others.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM