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
반응형
'C# > Unity' 카테고리의 다른 글
[Unity C#] 형변환 속도에 대해서 (int.Parse, ToString()) (2) | 2023.11.25 |
---|---|
[Unity C#] 기술 면접 대비 중급 질문들 (1) | 2023.11.14 |
[Unity C#] 기술 면접 대비 기본 질문들 (0) | 2023.11.14 |
[Unity C#] foreach GC에 대하여 (0) | 2023.11.13 |
[Unity C#] 유니티에서 Http 통신 (0) | 2023.09.09 |