浏览代码

updates

/main
kgc00 4 年前
当前提交
b06aad3e
共有 16 个文件被更改,包括 174 次插入233 次删除
  1. 15
      UOP1_Project/Assets/Prefabs/Characters/PigChef.prefab
  2. 88
      UOP1_Project/Assets/Scripts/Input/GameInput.cs
  3. 45
      UOP1_Project/Assets/Scripts/Input/InputReader.cs
  4. 12
      UOP1_Project/Assets/Scripts/Menu/CC_Button.cs
  5. 4
      UOP1_Project/Assets/Scripts/Menu/SelectableUIElement.cs
  6. 17
      UOP1_Project/Assets/Scripts/Menu/MenuSelectionHandler.cs
  7. 48
      UOP1_Project/Assets/Settings/Input/GameInput.inputactions
  8. 33
      UOP1_Project/Assets/Scripts/Menu/MenuInputController.cs
  9. 48
      UOP1_Project/Assets/Prefabs/Menu/debug menu controls.prefab
  10. 7
      UOP1_Project/Assets/Prefabs/Menu/debug menu controls.prefab.meta
  11. 46
      UOP1_Project/Assets/Scripts/Input/MenuInputReader.cs
  12. 11
      UOP1_Project/Assets/Scripts/Input/MenuInputReader.cs.meta
  13. 33
      UOP1_Project/Assets/Scripts/Menu/DebugMenu.cs
  14. 0
      /UOP1_Project/Assets/Scripts/Menu/MenuInputController.cs.meta
  15. 0
      /UOP1_Project/Assets/Scripts/Menu/MenuSelectionHandler.cs.meta
  16. 0
      /UOP1_Project/Assets/Scripts/Menu/MenuSelectionHandler.cs

15
UOP1_Project/Assets/Prefabs/Characters/PigChef.prefab


CurrentState:
debug: 0
_initialStateSO: {fileID: 11400000, guid: e128814ff6dbf63449bbc4dc8b6dc066, type: 2}
--- !u!114 &747238484418044736
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 309633228405838073}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bfb8a0b36800464dab759d2f75a1b6a0, type: 3}
m_Name:
m_EditorClassIdentifier:
_menuPrefab: {fileID: 9071686868156487228, guid: 0913fb2fbf6c4cb4aa9d88e5feaece97,
type: 3}
_inputReader: {fileID: 11400000, guid: 945ec0365077176418488737deed54be, type: 2}
--- !u!114 &3722006066079062647
MonoBehaviour:
m_ObjectHideFlags: 0

88
UOP1_Project/Assets/Scripts/Input/GameInput.cs


""id"": ""a6b0dc37-2ef3-420d-990a-eef5df26ae21"",
""actions"": [
{
""name"": ""MoveSelection"",
""name"": ""MoveMenuSelection"",
""type"": ""Value"",
""id"": ""ca8fee63-58a3-49c0-9b34-e74351e25113"",
""expectedControlType"": ""Vector2"",

""interactions"": """"
},
{
""name"": ""CloseMenu"",
""name"": ""Unpause"",
""type"": ""Button"",
""id"": ""a33f8309-65f3-4f8a-8671-c7cb90ef798e"",
""expectedControlType"": ""Button"",

""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""MoveSelection"",
""action"": ""MoveMenuSelection"",
""isComposite"": true,
""isPartOfComposite"": false
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveSelection"",
""action"": ""MoveMenuSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveSelection"",
""action"": ""MoveMenuSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveSelection"",
""action"": ""MoveMenuSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveSelection"",
""action"": ""MoveMenuSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""MoveSelection"",
""action"": ""MoveMenuSelection"",
""isComposite"": true,
""isPartOfComposite"": false
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveSelection"",
""action"": ""MoveMenuSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveSelection"",
""action"": ""MoveMenuSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveSelection"",
""action"": ""MoveMenuSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveSelection"",
""action"": ""MoveMenuSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""MoveSelection"",
""action"": ""MoveMenuSelection"",
""isComposite"": true,
""isPartOfComposite"": false
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveSelection"",
""action"": ""MoveMenuSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveSelection"",
""action"": ""MoveMenuSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveSelection"",
""action"": ""MoveMenuSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveSelection"",
""action"": ""MoveMenuSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""MoveSelection"",
""action"": ""MoveMenuSelection"",
""isComposite"": true,
""isPartOfComposite"": false
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveSelection"",
""action"": ""MoveMenuSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveSelection"",
""action"": ""MoveMenuSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveSelection"",
""action"": ""MoveMenuSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveSelection"",
""action"": ""MoveMenuSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""CloseMenu"",
""action"": ""Unpause"",
""isComposite"": false,
""isPartOfComposite"": false
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""CloseMenu"",
""action"": ""Unpause"",
""isComposite"": false,
""isPartOfComposite"": false
},

m_Gameplay_MouseControlCamera = m_Gameplay.FindAction("MouseControlCamera", throwIfNotFound: true);
// Menus
m_Menus = asset.FindActionMap("Menus", throwIfNotFound: true);
m_Menus_MoveSelection = m_Menus.FindAction("MoveSelection", throwIfNotFound: true);
m_Menus_MoveMenuSelection = m_Menus.FindAction("MoveMenuSelection", throwIfNotFound: true);
m_Menus_CloseMenu = m_Menus.FindAction("CloseMenu", throwIfNotFound: true);
m_Menus_Unpause = m_Menus.FindAction("Unpause", throwIfNotFound: true);
// Dialogues
m_Dialogues = asset.FindActionMap("Dialogues", throwIfNotFound: true);
m_Dialogues_MoveSelection = m_Dialogues.FindAction("MoveSelection", throwIfNotFound: true);

// Menus
private readonly InputActionMap m_Menus;
private IMenusActions m_MenusActionsCallbackInterface;
private readonly InputAction m_Menus_MoveSelection;
private readonly InputAction m_Menus_MoveMenuSelection;
private readonly InputAction m_Menus_CloseMenu;
private readonly InputAction m_Menus_Unpause;
public InputAction @MoveSelection => m_Wrapper.m_Menus_MoveSelection;
public InputAction @MoveMenuSelection => m_Wrapper.m_Menus_MoveMenuSelection;
public InputAction @CloseMenu => m_Wrapper.m_Menus_CloseMenu;
public InputAction @Unpause => m_Wrapper.m_Menus_Unpause;
public InputActionMap Get() { return m_Wrapper.m_Menus; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }

{
if (m_Wrapper.m_MenusActionsCallbackInterface != null)
{
@MoveSelection.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnMoveSelection;
@MoveSelection.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnMoveSelection;
@MoveSelection.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnMoveSelection;
@MoveMenuSelection.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnMoveMenuSelection;
@MoveMenuSelection.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnMoveMenuSelection;
@MoveMenuSelection.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnMoveMenuSelection;
@Confirm.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnConfirm;
@Confirm.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnConfirm;
@Confirm.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnConfirm;

@MouseMove.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnMouseMove;
@MouseMove.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnMouseMove;
@MouseMove.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnMouseMove;
@CloseMenu.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnCloseMenu;
@CloseMenu.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnCloseMenu;
@CloseMenu.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnCloseMenu;
@Unpause.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnUnpause;
@Unpause.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnUnpause;
@Unpause.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnUnpause;
@MoveSelection.started += instance.OnMoveSelection;
@MoveSelection.performed += instance.OnMoveSelection;
@MoveSelection.canceled += instance.OnMoveSelection;
@MoveMenuSelection.started += instance.OnMoveMenuSelection;
@MoveMenuSelection.performed += instance.OnMoveMenuSelection;
@MoveMenuSelection.canceled += instance.OnMoveMenuSelection;
@Confirm.started += instance.OnConfirm;
@Confirm.performed += instance.OnConfirm;
@Confirm.canceled += instance.OnConfirm;

@MouseMove.started += instance.OnMouseMove;
@MouseMove.performed += instance.OnMouseMove;
@MouseMove.canceled += instance.OnMouseMove;
@CloseMenu.started += instance.OnCloseMenu;
@CloseMenu.performed += instance.OnCloseMenu;
@CloseMenu.canceled += instance.OnCloseMenu;
@Unpause.started += instance.OnUnpause;
@Unpause.performed += instance.OnUnpause;
@Unpause.canceled += instance.OnUnpause;
}
}
}

}
public interface IMenusActions
{
void OnMoveSelection(InputAction.CallbackContext context);
void OnMoveMenuSelection(InputAction.CallbackContext context);
void OnCloseMenu(InputAction.CallbackContext context);
void OnUnpause(InputAction.CallbackContext context);
}
public interface IDialoguesActions
{

45
UOP1_Project/Assets/Scripts/Input/InputReader.cs


using UnityEngine.Events;
[CreateAssetMenu(fileName = "InputReader", menuName = "Game/Input Reader")]
public class InputReader : ScriptableObject, GameInput.IGameplayActions, GameInput.IDialoguesActions
public class InputReader : ScriptableObject, GameInput.IGameplayActions, GameInput.IDialoguesActions, GameInput.IMenusActions
{
// gameplay
public event UnityAction jumpEvent;

public event UnityAction advanceDialogueEvent = delegate { };
public event UnityAction onMoveSelectionEvent = delegate { };
public MenuInputReader Menu { get; private set; }
// MenuEvents
public event UnityAction MoveSelectionMenuEvent = delegate { };
public event UnityAction MouseMoveMenuEvent = delegate { };
public event UnityAction ConfirmMenuEvent = delegate { };
public event UnityAction CancelMenuEvent = delegate { };
public event UnityAction UnpauseMenuEvent = delegate { };
private GameInput gameInput;

{
gameInput = new GameInput();
Menu = new MenuInputReader(gameInput);
gameInput.Menus.SetCallbacks(this);
gameInput.Gameplay.SetCallbacks(this);
gameInput.Dialogues.SetCallbacks(this);
}

advanceDialogueEvent();
}
public void OnMoveMenuSelection(InputAction.CallbackContext context)
{
if (context.phase == InputActionPhase.Performed)
MoveSelectionMenuEvent();
}
public void OnConfirm(InputAction.CallbackContext context)
{
if (context.phase == InputActionPhase.Performed)
ConfirmMenuEvent();
}
public void OnCancel(InputAction.CallbackContext context)
{
if (context.phase == InputActionPhase.Performed)
CancelMenuEvent();
}
public void OnMouseMove(InputAction.CallbackContext context)
{
if (context.phase == InputActionPhase.Performed)
MouseMoveMenuEvent();
}
public void OnUnpause(InputAction.CallbackContext context)
{
if (context.phase == InputActionPhase.Performed)
UnpauseMenuEvent();
}
gameInput.Menus.Disable();
gameInput.Gameplay.Disable();
}

gameInput.Menus.Disable();
gameInput.Dialogues.Disable();
}

gameInput.Menus.Disable();
gameInput.Dialogues.Disable();
gameInput.Gameplay.Disable();
gameInput.Menus.Enable();
}

12
UOP1_Project/Assets/Scripts/Menu/CC_Button.cs


// Chop Chop button
public class CC_Button : Button
{
private MenuInput _menuInput;
private MenuSelectionHandler _menuSelectionHandler;
_menuInput = transform.root.gameObject.GetComponentInChildren<MenuInput>();
_menuSelectionHandler = transform.root.gameObject.GetComponentInChildren<MenuSelectionHandler>();
_menuInput.HandleMouseEnter(gameObject);
_menuSelectionHandler.HandleMouseEnter(gameObject);
_menuInput.HandleMouseExit(gameObject);
_menuSelectionHandler.HandleMouseExit(gameObject);
_menuInput.UpdateSelection(gameObject);
_menuSelectionHandler.UpdateSelection(gameObject);
if (_menuInput.AllowsSubmitOccurance(gameObject))
if (_menuSelectionHandler.AllowsSubmitOccurance())
base.OnSubmit(eventData);
}
}

4
UOP1_Project/Assets/Scripts/Menu/SelectableUIElement.cs


[AddComponentMenu("UI/SelectableUIElement")]
public class SelectableUIElement : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, ISelectHandler
{
private MenuInput _menuInput;
private MenuSelectionHandler _menuInput;
_menuInput = transform.root.gameObject.GetComponentInChildren<MenuInput>();
_menuInput = transform.root.gameObject.GetComponentInChildren<MenuSelectionHandler>();
}
public void OnPointerEnter(PointerEventData eventData)

17
UOP1_Project/Assets/Scripts/Menu/MenuSelectionHandler.cs


using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
public class MenuInput : MonoBehaviour
public class MenuSelectionHandler : MonoBehaviour
private GameObject _currentSelection;
private GameObject _mouseSelection;
public GameObject _currentSelection;
public GameObject _mouseSelection;
_inputReader.Menu.MouseMoveMenuEvent += HandleMoveCursor;
_inputReader.Menu.MoveSelectionMenuEvent += HandleMoveSelection;
_inputReader.MouseMoveMenuEvent += HandleMoveCursor;
_inputReader.MoveSelectionMenuEvent += HandleMoveSelection;
_inputReader.Menu.MouseMoveMenuEvent -= HandleMoveCursor;
_inputReader.Menu.MoveSelectionMenuEvent -= HandleMoveSelection;
_inputReader.MouseMoveMenuEvent -= HandleMoveCursor;
_inputReader.MoveSelectionMenuEvent -= HandleMoveSelection;
}
/// <summary>

/// <summary>
/// Method interactable UI elements should call on Submit interaction to determine whether to continue or not.
/// </summary>
/// <param name="o"></param>
public bool AllowsSubmitOccurance(GameObject o)
public bool AllowsSubmitOccurance()
{
// if LMB is not down, there is no edge case to handle, allow the event to continue
return !_inputReader.LeftMouseDown()

48
UOP1_Project/Assets/Settings/Input/GameInput.inputactions


"id": "a6b0dc37-2ef3-420d-990a-eef5df26ae21",
"actions": [
{
"name": "MoveSelection",
"name": "MoveMenuSelection",
"type": "Value",
"id": "ca8fee63-58a3-49c0-9b34-e74351e25113",
"expectedControlType": "Vector2",

"interactions": ""
},
{
"name": "CloseMenu",
"name": "Unpause",
"type": "Button",
"id": "a33f8309-65f3-4f8a-8671-c7cb90ef798e",
"expectedControlType": "Button",

"interactions": "",
"processors": "",
"groups": "",
"action": "MoveSelection",
"action": "MoveMenuSelection",
"isComposite": true,
"isPartOfComposite": false
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveSelection",
"action": "MoveMenuSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveSelection",
"action": "MoveMenuSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveSelection",
"action": "MoveMenuSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveSelection",
"action": "MoveMenuSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "",
"action": "MoveSelection",
"action": "MoveMenuSelection",
"isComposite": true,
"isPartOfComposite": false
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveSelection",
"action": "MoveMenuSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveSelection",
"action": "MoveMenuSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveSelection",
"action": "MoveMenuSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveSelection",
"action": "MoveMenuSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "",
"action": "MoveSelection",
"action": "MoveMenuSelection",
"isComposite": true,
"isPartOfComposite": false
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveSelection",
"action": "MoveMenuSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveSelection",
"action": "MoveMenuSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveSelection",
"action": "MoveMenuSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveSelection",
"action": "MoveMenuSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "",
"action": "MoveSelection",
"action": "MoveMenuSelection",
"isComposite": true,
"isPartOfComposite": false
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveSelection",
"action": "MoveMenuSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveSelection",
"action": "MoveMenuSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveSelection",
"action": "MoveMenuSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveSelection",
"action": "MoveMenuSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "CloseMenu",
"action": "Unpause",
"isComposite": false,
"isPartOfComposite": false
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "CloseMenu",
"action": "Unpause",
"isComposite": false,
"isPartOfComposite": false
},

33
UOP1_Project/Assets/Scripts/Menu/MenuInputController.cs


using System;
using UnityEngine;
public class MenuInputController : MonoBehaviour
{
[SerializeField] private GameObject _menuPrefab;
private GameObject _menuInstance;
[SerializeField] private InputReader _inputReader;
private void OnEnable()
{
_inputReader.pauseEvent += OpenMenu;
_inputReader.UnpauseMenuEvent += UnpauseMenu;
}
private void OnDisable()
{
_inputReader.pauseEvent -= OpenMenu;
_inputReader.UnpauseMenuEvent -= UnpauseMenu;
}
private void OpenMenu()
{
if (_menuInstance == null) _menuInstance = Instantiate(_menuPrefab);
_menuInstance.SetActive(true);
_inputReader.EnableMenuInput();
}
private void UnpauseMenu()
{
_menuInstance.SetActive(false);
_inputReader.EnableGameplayInput();
}
}

48
UOP1_Project/Assets/Prefabs/Menu/debug menu controls.prefab


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &7576039656433302283
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7581178889969359010}
- component: {fileID: 7601654174107061493}
m_Layer: 0
m_Name: debug menu controls
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7581178889969359010
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7576039656433302283}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 269.8174, y: 159.33746, z: 623.1245}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &7601654174107061493
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7576039656433302283}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bfb8a0b36800464dab759d2f75a1b6a0, type: 3}
m_Name:
m_EditorClassIdentifier:
_menuPrefab: {fileID: 9071686868156487228, guid: 0913fb2fbf6c4cb4aa9d88e5feaece97,
type: 3}
_inputReader: {fileID: 11400000, guid: 945ec0365077176418488737deed54be, type: 2}

7
UOP1_Project/Assets/Prefabs/Menu/debug menu controls.prefab.meta


fileFormatVersion: 2
guid: b32688bd582a7ad479d51d1547d5b22f
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

46
UOP1_Project/Assets/Scripts/Input/MenuInputReader.cs


using UnityEngine.Events;
using UnityEngine.InputSystem;
public class MenuInputReader: GameInput.IMenusActions
{
public MenuInputReader(GameInput gameInput)
{
gameInput.Menus.SetCallbacks(this);
}
// MenuEvents
public event UnityAction MoveSelectionMenuEvent = delegate { };
public event UnityAction MouseMoveMenuEvent = delegate { };
public event UnityAction ConfirmMenuEvent = delegate { };
public event UnityAction CancelMenuEvent = delegate { };
public event UnityAction CloseMenuEvent = delegate { };
public void OnMoveSelection(InputAction.CallbackContext context)
{
if (context.phase == InputActionPhase.Performed)
MoveSelectionMenuEvent();
}
public void OnConfirm(InputAction.CallbackContext context)
{
if (context.phase == InputActionPhase.Performed)
ConfirmMenuEvent();
}
public void OnCancel(InputAction.CallbackContext context)
{
if (context.phase == InputActionPhase.Performed)
CancelMenuEvent();
}
public void OnMouseMove(InputAction.CallbackContext context)
{
if (context.phase == InputActionPhase.Performed)
MouseMoveMenuEvent();
}
public void OnCloseMenu(InputAction.CallbackContext context)
{
if (context.phase == InputActionPhase.Performed)
CloseMenuEvent();
}
}

11
UOP1_Project/Assets/Scripts/Input/MenuInputReader.cs.meta


fileFormatVersion: 2
guid: 028af03e2ac34463b1c2b1ba0ee23809
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

33
UOP1_Project/Assets/Scripts/Menu/DebugMenu.cs


using System;
using UnityEngine;
public class DebugMenu : MonoBehaviour
{
[SerializeField] private GameObject _menuPrefab;
private GameObject _menuInstance;
[SerializeField] private InputReader _inputReader;
private void OnEnable()
{
_inputReader.pauseEvent += OpenMenu;
_inputReader.Menu.CloseMenuEvent += CloseMenu;
}
private void OnDisable()
{
_inputReader.pauseEvent -= OpenMenu;
_inputReader.Menu.CloseMenuEvent -= CloseMenu;
}
private void OpenMenu()
{
if (_menuInstance == null) _menuInstance = Instantiate(_menuPrefab);
_menuInstance.SetActive(true);
_inputReader.EnableMenuInput();
}
private void CloseMenu()
{
_menuInstance.SetActive(false);
_inputReader.EnableGameplayInput();
}
}

/UOP1_Project/Assets/Scripts/Menu/DebugMenu.cs.meta → /UOP1_Project/Assets/Scripts/Menu/MenuInputController.cs.meta

/UOP1_Project/Assets/Scripts/Menu/MenuInput.cs.meta → /UOP1_Project/Assets/Scripts/Menu/MenuSelectionHandler.cs.meta

/UOP1_Project/Assets/Scripts/Menu/MenuInput.cs → /UOP1_Project/Assets/Scripts/Menu/MenuSelectionHandler.cs

正在加载...
取消
保存