using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

public class DialogChoiceRow : MonoBehaviour
{
    [SerializeField] private TMP_Text _text;
    [SerializeField] private Button _button;

    public event Action<int> OnClicked;

    private int _index;

    private void Awake()
    {
        if (_button != null)
            _button.onClick.AddListener(() => OnClicked?.Invoke(_index));
    }

    public void Bind(int index, string text)
    {
        _index = index;
        if (_text != null) _text.text = text;
    }
}
