kgc00
4 年前
当前提交
b06aad3e
共有 16 个文件被更改,包括 174 次插入 和 233 次删除
-
15UOP1_Project/Assets/Prefabs/Characters/PigChef.prefab
-
88UOP1_Project/Assets/Scripts/Input/GameInput.cs
-
45UOP1_Project/Assets/Scripts/Input/InputReader.cs
-
12UOP1_Project/Assets/Scripts/Menu/CC_Button.cs
-
4UOP1_Project/Assets/Scripts/Menu/SelectableUIElement.cs
-
17UOP1_Project/Assets/Scripts/Menu/MenuSelectionHandler.cs
-
48UOP1_Project/Assets/Settings/Input/GameInput.inputactions
-
33UOP1_Project/Assets/Scripts/Menu/MenuInputController.cs
-
48UOP1_Project/Assets/Prefabs/Menu/debug menu controls.prefab
-
7UOP1_Project/Assets/Prefabs/Menu/debug menu controls.prefab.meta
-
46UOP1_Project/Assets/Scripts/Input/MenuInputReader.cs
-
11UOP1_Project/Assets/Scripts/Input/MenuInputReader.cs.meta
-
33UOP1_Project/Assets/Scripts/Menu/DebugMenu.cs
-
0/UOP1_Project/Assets/Scripts/Menu/MenuInputController.cs.meta
-
0/UOP1_Project/Assets/Scripts/Menu/MenuSelectionHandler.cs.meta
-
0/UOP1_Project/Assets/Scripts/Menu/MenuSelectionHandler.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(); |
|||
} |
|||
} |
|
|||
%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} |
|
|||
fileFormatVersion: 2 |
|||
guid: b32688bd582a7ad479d51d1547d5b22f |
|||
PrefabImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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(); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 028af03e2ac34463b1c2b1ba0ee23809 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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(); |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue