Files
ichni_Official/Assets/Scripts/UI/DialogUI/ChoiceFrame.cs
SoulliesOfficial db4d131192 1
2025-06-06 10:14:55 -04:00

48 lines
1.6 KiB
C#

using System.Collections;
using System.Collections.Generic;
using Michsky.MUIP;
using Sirenix.Utilities;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace Ichni.Story
{
public class ChoiceFrame : MonoBehaviour
{
public GameObject choiceButtonPrefab;
public RectTransform choiceButtonContainer;
public List<Button> choiceButtonList;
public TooltipContent hint;
public void PlayChoice(List<Choice> choices)
{
gameObject.SetActive(true);
choiceButtonContainer.GetAllChildren().ForEach(x => Destroy(x.gameObject));
choiceButtonList.Clear();
/*if (choiceModule.hint != "")
{
hint.gameObject.SetActive(true);
hint.description = choiceModule.hint;
}
else
{
hint.gameObject.SetActive(false);
}*/
foreach (var choice in choices)
{
GameObject choiceButton = Instantiate(choiceButtonPrefab, choiceButtonContainer);
choiceButton.GetComponentInChildren<TMP_Text>().text = choice.choiceText;
choiceButton.GetComponent<Button>().onClick.AddListener(() =>
{
DialogManager.instance.PlayNextDialogParagraph(choice.nextDialogName);
DialogManager.instance.isPlayingChoice = false;
gameObject.SetActive(false);
});
choiceButtonList.Add(choiceButton.GetComponent<Button>());
}
}
}
}