728x90
반응형
[SerializeField]
private Image Bar;       
[SerializeField]
private RectTransform SpeechBubble;

private float count;
private float maxcount

Bar.fillAmount = count / maxcount;

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

유니티에서 FillAmount를 사용하는 경우가 많은데 FillAmount의 끝자리에 특정한 오브젝트가 위치하도록 하는 코드이다.

 

728x90
반응형

+ Recent posts