fix radial menu
This commit is contained in:
@@ -9258,7 +9258,7 @@ MonoBehaviour:
|
|||||||
_jobSelectorPrefab: {fileID: 3776407727599883163, guid: 2ad5edd099127044684eeca456ed3d00,
|
_jobSelectorPrefab: {fileID: 3776407727599883163, guid: 2ad5edd099127044684eeca456ed3d00,
|
||||||
type: 3}
|
type: 3}
|
||||||
_blurOverlay: {fileID: 1972616679270001457}
|
_blurOverlay: {fileID: 1972616679270001457}
|
||||||
_itemPopupMenuPrefab: {fileID: 5424962769672562944, guid: 543443cf1b9e73b4193a13044eda04d2,
|
_radialMenuItemPrefab: {fileID: 5424962769672562944, guid: 543443cf1b9e73b4193a13044eda04d2,
|
||||||
type: 3}
|
type: 3}
|
||||||
--- !u!222 &1315590696984075725
|
--- !u!222 &1315590696984075725
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
|
|||||||
@@ -15,27 +15,30 @@ public class BaseInteractableObject : MonoBehaviour
|
|||||||
public InteractionStatus Interact(Player player)
|
public InteractionStatus Interact(Player player)
|
||||||
{
|
{
|
||||||
_player = player;
|
_player = player;
|
||||||
if (_currentStatus == InteractionStatus.None && _menuActions.Any())
|
switch (_currentStatus)
|
||||||
{
|
{
|
||||||
UIManager.Instance.ShowItemsMenu(_menuActions, PopupMenuCallback);
|
case InteractionStatus.None when _menuActions.Any():
|
||||||
_currentStatus = InteractionStatus.WaitForChoose;
|
UIManager.Instance.ShowItemsMenu(_menuActions, PopupMenuCallback);
|
||||||
}
|
_currentStatus = InteractionStatus.WaitForChoose;
|
||||||
else if (_currentStatus == InteractionStatus.Complete)
|
break;
|
||||||
{
|
case InteractionStatus.Complete:
|
||||||
_currentStatus = InteractionStatus.None;
|
_currentStatus = InteractionStatus.None;
|
||||||
return InteractionStatus.Complete;
|
return InteractionStatus.Complete;
|
||||||
}
|
default:
|
||||||
else if (_currentStatus != InteractionStatus.WaitForChoose && _currentStatus != InteractionStatus.Complete)
|
if (_currentStatus != InteractionStatus.WaitForChoose && _currentStatus != InteractionStatus.Complete)
|
||||||
{
|
{
|
||||||
if (_player.IsPathComplete(_interactionPoint.position))
|
if (_player.IsPathComplete(_interactionPoint.position))
|
||||||
{
|
{
|
||||||
InteractAction();
|
InteractAction();
|
||||||
_currentStatus = InteractionStatus.Complete;
|
_currentStatus = InteractionStatus.None;
|
||||||
}
|
return InteractionStatus.Complete;
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
_currentStatus = InteractionStatus.FarFromPlayer;
|
{
|
||||||
}
|
_currentStatus = InteractionStatus.FarFromPlayer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return _currentStatus;
|
return _currentStatus;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,9 +8,13 @@ public class RadialMenuItem : MonoBehaviour
|
|||||||
{
|
{
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private Button _radialMenuItemPrefab;
|
private Button _radialMenuItemPrefab;
|
||||||
|
private Action<RadialMenuActionSO> _menuButtonClick=null;
|
||||||
|
List<RadialMenuActionSO> _actions;
|
||||||
|
|
||||||
public void ShowButtons(List<RadialMenuActionSO> actions, Action<RadialMenuActionSO> menuButtonClick)
|
public void ShowButtons(List<RadialMenuActionSO> actions, Action<RadialMenuActionSO> menuButtonClick)
|
||||||
{
|
{
|
||||||
|
_actions = actions;
|
||||||
|
_menuButtonClick = menuButtonClick;
|
||||||
for (int buttonsCount = 0; buttonsCount < actions.Count; buttonsCount++)
|
for (int buttonsCount = 0; buttonsCount < actions.Count; buttonsCount++)
|
||||||
{
|
{
|
||||||
var button = Instantiate(_radialMenuItemPrefab);
|
var button = Instantiate(_radialMenuItemPrefab);
|
||||||
@@ -27,14 +31,20 @@ public class RadialMenuItem : MonoBehaviour
|
|||||||
textMeshPro.text = actions[buttonsCount].ActionName;
|
textMeshPro.text = actions[buttonsCount].ActionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
button.onClick.AddListener(() =>
|
AddEvent(button, buttonsCount);
|
||||||
{
|
|
||||||
Hide();
|
|
||||||
CloseDialog();
|
|
||||||
menuButtonClick?.Invoke(actions[1]);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddEvent(Button b, int i)
|
||||||
|
{
|
||||||
|
b.onClick.AddListener(() =>
|
||||||
|
{
|
||||||
|
Hide();
|
||||||
|
_menuButtonClick?.Invoke(_actions[i]);
|
||||||
|
CloseDialog();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void CloseDialog()
|
private void CloseDialog()
|
||||||
{
|
{
|
||||||
UIManager.Instance.Unfreeze();
|
UIManager.Instance.Unfreeze();
|
||||||
|
|||||||
Reference in New Issue
Block a user