77 lines
2.6 KiB
C#
77 lines
2.6 KiB
C#
|
|
using System;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.UI;
|
|||
|
|
using TMPro;
|
|||
|
|
|
|||
|
|
// <20>˾<EFBFBD> <20><><EFBFBD><EFBFBD> Ÿ<><C5B8>
|
|||
|
|
public enum PopupResponse
|
|||
|
|
{
|
|||
|
|
Confirm, // Ȯ<><C8AE>
|
|||
|
|
Cancel, // <20><><EFBFBD><EFBFBD>
|
|||
|
|
Option1, // (<28><>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>̵<EFBFBD>)
|
|||
|
|
Option2 // (<28><>: <20><><EFBFBD><EFBFBD>)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public interface IPopupView
|
|||
|
|
{
|
|||
|
|
event Action<PopupResponse> OnPopupResponse;
|
|||
|
|
void ShowConfirmPopup(string title, string message); // 2, 5<>ܰ<EFBFBD><DCB0><EFBFBD> (Ȯ<><C8AE>/<2F><><EFBFBD><EFBFBD>)
|
|||
|
|
void ShowOptionPopup(string title, string message, string opt1Text, string opt2Text); // 8<>ܰ<EFBFBD><DCB0><EFBFBD> (<28>̵<EFBFBD>/<2F><><EFBFBD><EFBFBD>)
|
|||
|
|
void HidePopup();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public class PopupView : MonoBehaviour, IPopupView
|
|||
|
|
{
|
|||
|
|
public event Action<PopupResponse> OnPopupResponse;
|
|||
|
|
|
|||
|
|
[SerializeField] private GameObject popupPanel;
|
|||
|
|
[SerializeField] private TextMeshProUGUI titleText;
|
|||
|
|
[SerializeField] private TextMeshProUGUI messageText;
|
|||
|
|
|
|||
|
|
[SerializeField] private Button confirmButton; // 'Ȯ<><C8AE>' <20><>ư
|
|||
|
|
[SerializeField] private Button cancelButton; // '<27><><EFBFBD><EFBFBD>' <20><>ư
|
|||
|
|
[SerializeField] private Button option1Button; // '<27>ɼ<EFBFBD>1(<28>̵<EFBFBD>)' <20><>ư
|
|||
|
|
[SerializeField] private Button option2Button; // '<27>ɼ<EFBFBD>2(<28><><EFBFBD><EFBFBD>)' <20><>ư
|
|||
|
|
|
|||
|
|
void Start()
|
|||
|
|
{
|
|||
|
|
// <20><> <20><>ư<EFBFBD><C6B0> Ŭ<><C5AC><EFBFBD>Ǹ<EFBFBD> Presenter<65><72><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>̺<EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD>
|
|||
|
|
confirmButton.onClick.AddListener(() => OnPopupResponse?.Invoke(PopupResponse.Confirm));
|
|||
|
|
cancelButton.onClick.AddListener(() => OnPopupResponse?.Invoke(PopupResponse.Cancel));
|
|||
|
|
option1Button.onClick.AddListener(() => OnPopupResponse?.Invoke(PopupResponse.Option1));
|
|||
|
|
option2Button.onClick.AddListener(() => OnPopupResponse?.Invoke(PopupResponse.Option2));
|
|||
|
|
|
|||
|
|
popupPanel.SetActive(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void ShowConfirmPopup(string title, string message)
|
|||
|
|
{
|
|||
|
|
titleText.text = title;
|
|||
|
|
messageText.text = message;
|
|||
|
|
confirmButton.gameObject.SetActive(true);
|
|||
|
|
cancelButton.gameObject.SetActive(true);
|
|||
|
|
option1Button.gameObject.SetActive(false);
|
|||
|
|
option2Button.gameObject.SetActive(false);
|
|||
|
|
popupPanel.SetActive(true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void ShowOptionPopup(string title, string message, string opt1Text, string opt2Text)
|
|||
|
|
{
|
|||
|
|
titleText.text = title;
|
|||
|
|
messageText.text = message;
|
|||
|
|
option1Button.GetComponentInChildren<Text>().text = opt1Text;
|
|||
|
|
option2Button.GetComponentInChildren<Text>().text = opt2Text;
|
|||
|
|
|
|||
|
|
confirmButton.gameObject.SetActive(false);
|
|||
|
|
cancelButton.gameObject.SetActive(true); // <20><><EFBFBD><EFBFBD> <20><>ư<EFBFBD><C6B0> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
|
option1Button.gameObject.SetActive(true);
|
|||
|
|
option2Button.gameObject.SetActive(true);
|
|||
|
|
popupPanel.SetActive(true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void HidePopup()
|
|||
|
|
{
|
|||
|
|
popupPanel.SetActive(false);
|
|||
|
|
}
|
|||
|
|
}
|