41 lines
1015 B
C#
41 lines
1015 B
C#
using System;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace AibisDream
|
|
{
|
|
public class BubbleOption : MonoBehaviour
|
|
{
|
|
public int optionIdx;
|
|
private TMP_Text _text;
|
|
private DialogOption _option;
|
|
private Button _button;
|
|
|
|
public void Awake()
|
|
{
|
|
_text = GetComponentInChildren<TMP_Text>();
|
|
_button = GetComponent<Button>();
|
|
}
|
|
|
|
public void ShowOption(DialogOption dialogOption, Action hide)
|
|
{
|
|
gameObject.SetActive(true);
|
|
_button.onClick.RemoveAllListeners();
|
|
_text.text = "";
|
|
// 清理旧数据
|
|
gameObject.SetActive(true);
|
|
_text.text = dialogOption.Line;
|
|
_button.onClick.AddListener(() =>
|
|
{
|
|
hide?.Invoke();
|
|
dialogOption.Select();
|
|
});
|
|
}
|
|
|
|
public void Hide()
|
|
{
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|
|
} |