refactor interact system
interact only after PopupItemMenu button clicked
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@@ -6,10 +8,27 @@ public class PopupItemMenu : MonoBehaviour
|
||||
[SerializeField]
|
||||
private Button _popupMenuItemButtonPrefab;
|
||||
|
||||
public void ShowButtons()
|
||||
public void ShowButtons(Action menuButtonClick)
|
||||
{
|
||||
var button=Instantiate(_popupMenuItemButtonPrefab) as Button;
|
||||
button.transform.SetParent(transform,false);
|
||||
button.transform.localPosition = new Vector3(0, 100f, 0);
|
||||
|
||||
button.onClick.AddListener(() =>
|
||||
{
|
||||
menuButtonClick?.Invoke();
|
||||
Hide();
|
||||
CloseDialog();
|
||||
});
|
||||
}
|
||||
private void CloseDialog()
|
||||
{
|
||||
UIManager.Instance.Unfreeze();
|
||||
Destroy(this);
|
||||
}
|
||||
|
||||
private void Hide()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,12 +40,12 @@ public class UIManager : MonoBehaviour
|
||||
jobSelector.ShowJobSelectionDialog(title, onCancel, onConfirm);
|
||||
}
|
||||
|
||||
public void ShowItemsMenu()
|
||||
public void ShowItemsMenu(Action itemsMenuCallback)
|
||||
{
|
||||
var popupMenu = Instantiate(_itemPopupMenuPrefab) as PopupItemMenu;
|
||||
popupMenu.transform.transform.SetParent(transform, false);
|
||||
popupMenu.transform.position = Input.mousePosition;
|
||||
popupMenu.ShowButtons();
|
||||
popupMenu.ShowButtons(itemsMenuCallback);
|
||||
}
|
||||
|
||||
public void Freeze()
|
||||
|
||||
Reference in New Issue
Block a user