'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



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ashik