36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using NEG.UI.Popup;
|
|
using NEG.UI.UnityUi.Buttons;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
namespace NEG.UI.UnityUi.Popup
|
|
{
|
|
public class MonoDefaultPopup : MonoPopup, IDefaultPopup
|
|
{
|
|
[SerializeField] private TMP_Text titleText;
|
|
[SerializeField] private TMP_Text contentText;
|
|
[SerializeField] private Transform buttonsParent;
|
|
[SerializeField] private BaseButton buttonPrefab;
|
|
|
|
public void SetContent(string title, string content, List<(string, Action)> options)
|
|
{
|
|
foreach (Transform child in buttonsParent)
|
|
{
|
|
Destroy(child.gameObject);
|
|
}
|
|
|
|
titleText.text = title;
|
|
contentText.text = content;
|
|
|
|
foreach ((string text, Action action) item in options)
|
|
{
|
|
var button = Instantiate(buttonPrefab, buttonsParent);
|
|
button.SetText(item.text);
|
|
button.OnButtonPressed += item.action;
|
|
button.OnButtonPressed += () => Close();
|
|
}
|
|
}
|
|
}
|
|
} |