1
This commit is contained in:
48
Assets/Scripts/UI/DialogUI/ChoiceFrame.cs
Normal file
48
Assets/Scripts/UI/DialogUI/ChoiceFrame.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
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>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user