using System; using UnityEngine; using UnityEngine.UI; using System.Collections; public enum PopupResponse { InsConfirm, // ±â·Ï È®Á¤ ModConfirm, // ¼öÁ¤ È®Á¤ Move, // ¿©±â·Î À̵¿ Delete, // »èÁ¦ DelConfirm, // »èÁ¦ È®Á¤ Cancel // Ãë¼Ò } public class PopupView : MonoBehaviour { public event Action OnPopupResponse; [SerializeField] private GameObject confirmPopupPanel; [SerializeField] private GameObject modifyPopupPanel; [SerializeField] private GameObject deletePopupPanel; [SerializeField] private GameObject optionPopupPanel; [SerializeField] private GameObject errorAlert; [SerializeField] private Button ins_confirmButton; // '±â·ÏÈ®Á¤' ¹öư [SerializeField] private Button mod_confirmButton; // '¼öÁ¤È®Á¤' ¹öư [SerializeField] private Button moveButton; // 'À̵¿' ¹öư [SerializeField] private Button deleteButton; // '»èÁ¦' ¹öư [SerializeField] private Button del_confirmButton; // '»èÁ¦È®Á¤' ¹öư [SerializeField] private Button[] cancelButton; // 'Ãë¼Ò' ¹öư private Coroutine autoHideCoroutine; void Start() { ins_confirmButton.onClick.AddListener(() => OnPopupResponse?.Invoke(PopupResponse.InsConfirm)); mod_confirmButton.onClick.AddListener(() => OnPopupResponse?.Invoke(PopupResponse.ModConfirm)); moveButton.onClick.AddListener(() => OnPopupResponse?.Invoke(PopupResponse.Move)); deleteButton.onClick.AddListener(() => OnPopupResponse?.Invoke(PopupResponse.Delete)); del_confirmButton.onClick.AddListener(() => OnPopupResponse?.Invoke(PopupResponse.DelConfirm)); for (int i = 0; i < cancelButton.Length; i++) cancelButton[i].onClick.AddListener(() => OnPopupResponse?.Invoke(PopupResponse.Cancel)); confirmPopupPanel.SetActive(false); modifyPopupPanel.SetActive(false); deletePopupPanel.SetActive(false); optionPopupPanel.SetActive(false); } public void ShowConfirmPopupFromRobot(Transform popPose) { //confirmPopupPanel.transform.position = popPose.position; //confirmPopupPanel.transform.LookAt(Camera.main.transform); //confirmPopupPanel.transform.Rotate(0, 180, 0); confirmPopupPanel.SetActive(true); } public void ShowConfirmPopupFromPoint(Vector3 popPose) { //confirmPopupPanel.transform.position = popPose; //confirmPopupPanel.transform.LookAt(Camera.main.transform); //confirmPopupPanel.transform.Rotate(0, 180, 0); confirmPopupPanel.SetActive(true); } public void ShowModifyPopup(Vector3 popPose) { //modifyPopupPanel.transform.position = popPose; //modifyPopupPanel.transform.LookAt(Camera.main.transform); //modifyPopupPanel.transform.Rotate(0, 180, 0); modifyPopupPanel.SetActive(true); } public void ShowDeletePopup(Vector3 popPose) { //deletePopupPanel.transform.position = popPose; //deletePopupPanel.transform.LookAt(Camera.main.transform); //deletePopupPanel.transform.Rotate(0, 180, 0); deletePopupPanel.SetActive(true); } public void ShowOptionPopup(Vector3 popPose) { optionPopupPanel.transform.position = popPose; optionPopupPanel.transform.localRotation = Quaternion.identity; //optionPopupPanel.transform.LookAt(Camera.main.transform); //optionPopupPanel.transform.Rotate(0, 180, 0); optionPopupPanel.SetActive(true); } public void ShowErrorAlert(bool show, float duration = 2.0f) { if (autoHideCoroutine != null) { StopCoroutine(autoHideCoroutine); autoHideCoroutine = null; } if (errorAlert != null) { errorAlert.SetActive(show); } if (show && duration > 0) { autoHideCoroutine = StartCoroutine(AutoHideCoroutine(duration)); } } // ÁöÁ¤µÈ ½Ã°£ µÚ¿¡ ÆË¾÷À» ²ô´Â ÄÚ·çÆ¾ private IEnumerator AutoHideCoroutine(float delay) { yield return new WaitForSeconds(delay); if (errorAlert != null) { errorAlert.SetActive(false); } autoHideCoroutine = null; } public void HidePopup() { confirmPopupPanel.SetActive(false); modifyPopupPanel.SetActive(false); deletePopupPanel.SetActive(false); optionPopupPanel.SetActive(false); errorAlert.SetActive(false); } }