using UnityEngine;
using TMPro;
public class SpeechBubble : MonoBehaviour
{
public TextMeshProUGUI Speechtext; // 말풍선 텍스트
public RectTransform rectSpeechBubble;// 말풍선 위치
public float paddingOffset = 100.0f; // 패딩의 offset
void Update()
{
// 말풍선 y축 패딩값을 적용후 사이즈 변경
rectSpeechBubble.SetSizeWithCurrentAnchors
(RectTransform.Axis.Vertical, Speechtext.textBounds.size.y + paddingOffset);
// 말풍선 x축 패딩값을 적용후 사이즈 변경
rectSpeechBubble.SetSizeWithCurrentAnchors
(RectTransform.Axis.Horizontal, Speechtext.textBounds.size.x + paddingOffset);
}
}
'개발💻 > Unity' 카테고리의 다른 글
[Unity] New input system 3 ( Behavior 설정 with code ) (0) | 2024.05.18 |
---|---|
[Unity] New input system 2 ( New input system 환경 설정 ) (0) | 2024.05.18 |
[Unity] New input system 1 ( 개념 정리 ) (0) | 2024.04.21 |
[Unity] 텍스트 끝에 이모지 생성 (0) | 2022.10.04 |
[Unity] Addressable Asset System (1) | 2022.09.20 |