대화로직 수정중
This commit is contained in:
@@ -16,6 +16,12 @@ public class ChoiceHud : MonoBehaviour
|
||||
[SerializeField] private TMP_Text ChoiceQuestion;
|
||||
[SerializeField] private RectTransform _ScrollRect;
|
||||
|
||||
[Header("Layout")]
|
||||
[Tooltip("선택지 한 줄의 높이")]
|
||||
[SerializeField] private float _rowHeight = 40f;
|
||||
[Tooltip("이 줄 수까지만 높이를 늘리고, 넘어가면 스크롤로 본다")]
|
||||
[SerializeField] private int _maxVisibleRows = 3;
|
||||
|
||||
private readonly List<DialogChoiceRow> _rows = new();
|
||||
private AwaitableCompletionSource<int> _completion;
|
||||
|
||||
@@ -52,6 +58,7 @@ public async Awaitable<int> Show(string choiceQuestion, List<DialogChoice> choic
|
||||
row.OnClicked += HandleClicked;
|
||||
_rows.Add(row);
|
||||
}
|
||||
ResizeToRowCount(choices.Count);
|
||||
|
||||
_root.SetActive(true);
|
||||
_completion = new AwaitableCompletionSource<int>();
|
||||
@@ -74,6 +81,15 @@ private void HandleClicked(int index)
|
||||
_completion?.TrySetResult(index);
|
||||
}
|
||||
|
||||
// 선택지 개수에 맞춰 스크롤 영역 높이 조절 (1개=40, 2개=80, 3개=120 …).
|
||||
// _maxVisibleRows를 넘는 개수는 높이를 더 늘리지 않고 스크롤로 본다.
|
||||
private void ResizeToRowCount(int count)
|
||||
{
|
||||
if (_ScrollRect == null) return;
|
||||
int visibleRows = Mathf.Min(count, _maxVisibleRows);
|
||||
_ScrollRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, visibleRows * _rowHeight);
|
||||
}
|
||||
|
||||
private void Hide()
|
||||
{
|
||||
SetQuestion(null);
|
||||
|
||||
Reference in New Issue
Block a user