44 lines
1.0 KiB
C#
44 lines
1.0 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class PopupItemMenu : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private Button _popupMenuItemButtonPrefab;
|
|
|
|
public void ShowButtons(List<ItemsMenuActionSO> actions, Action menuButtonClick)
|
|
{
|
|
var button = Instantiate(_popupMenuItemButtonPrefab) as Button;
|
|
button.transform.SetParent(transform, false);
|
|
button.transform.localPosition = new Vector3(0, 100f, 0);
|
|
|
|
var textMeshPro = button.GetComponent<TextMeshPro>();
|
|
if (textMeshPro != null)
|
|
{
|
|
textMeshPro.text = actions[0].ActionName;
|
|
}
|
|
|
|
|
|
button.onClick.AddListener(() =>
|
|
{
|
|
menuButtonClick?.Invoke();
|
|
Hide();
|
|
CloseDialog();
|
|
});
|
|
}
|
|
private void CloseDialog()
|
|
{
|
|
UIManager.Instance.Unfreeze();
|
|
Destroy(this);
|
|
}
|
|
|
|
private void Hide()
|
|
{
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|