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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user