From 5f6fc9de29808d9205468e87f6db63e0e46fc1ac Mon Sep 17 00:00:00 2001 From: Harsh Narayan Jha <50262541+HarshNarayanJha@users.noreply.github.com> Date: Mon, 2 Aug 2021 19:21:22 +0530 Subject: [PATCH 1/9] Create Debug Input --- .../Assets/Scripts/Input/GameInput.cs | 29 +++++++++++++++++++ .../Assets/Scripts/Input/InputReader.cs | 7 +++++ .../Settings/Input/GameInput.inputactions | 19 ++++++++++++ 3 files changed, 55 insertions(+) diff --git a/UOP1_Project/Assets/Scripts/Input/GameInput.cs b/UOP1_Project/Assets/Scripts/Input/GameInput.cs index 1fb90ec088..6b8e23bd1d 100644 --- a/UOP1_Project/Assets/Scripts/Input/GameInput.cs +++ b/UOP1_Project/Assets/Scripts/Input/GameInput.cs @@ -89,6 +89,14 @@ public @GameInput() ""expectedControlType"": ""Button"", ""processors"": """", ""interactions"": """" + }, + { + ""name"": ""OpenDebugMenu"", + ""type"": ""Button"", + ""id"": ""01cc35a0-576f-4d88-9bd1-7de987c51f52"", + ""expectedControlType"": ""Button"", + ""processors"": """", + ""interactions"": """" } ], ""bindings"": [ @@ -487,6 +495,17 @@ public @GameInput() ""action"": ""Run"", ""isComposite"": false, ""isPartOfComposite"": false + }, + { + ""name"": """", + ""id"": ""fa641624-9abb-4037-b855-92c4f1c79f94"", + ""path"": ""/backquote"", + ""interactions"": """", + ""processors"": """", + ""groups"": ""KeyboardOrGamepad"", + ""action"": ""OpenDebugMenu"", + ""isComposite"": false, + ""isPartOfComposite"": false } ] }, @@ -1663,6 +1682,7 @@ public @GameInput() m_Gameplay_RotateCamera = m_Gameplay.FindAction("RotateCamera", throwIfNotFound: true); m_Gameplay_MouseControlCamera = m_Gameplay.FindAction("MouseControlCamera", throwIfNotFound: true); m_Gameplay_Run = m_Gameplay.FindAction("Run", throwIfNotFound: true); + m_Gameplay_OpenDebugMenu = m_Gameplay.FindAction("OpenDebugMenu", throwIfNotFound: true); // Menus m_Menus = asset.FindActionMap("Menus", throwIfNotFound: true); m_Menus_MoveSelection = m_Menus.FindAction("MoveSelection", throwIfNotFound: true); @@ -1740,6 +1760,7 @@ public void Disable() private readonly InputAction m_Gameplay_RotateCamera; private readonly InputAction m_Gameplay_MouseControlCamera; private readonly InputAction m_Gameplay_Run; + private readonly InputAction m_Gameplay_OpenDebugMenu; public struct GameplayActions { private @GameInput m_Wrapper; @@ -1753,6 +1774,7 @@ public struct GameplayActions public InputAction @RotateCamera => m_Wrapper.m_Gameplay_RotateCamera; public InputAction @MouseControlCamera => m_Wrapper.m_Gameplay_MouseControlCamera; public InputAction @Run => m_Wrapper.m_Gameplay_Run; + public InputAction @OpenDebugMenu => m_Wrapper.m_Gameplay_OpenDebugMenu; public InputActionMap Get() { return m_Wrapper.m_Gameplay; } public void Enable() { Get().Enable(); } public void Disable() { Get().Disable(); } @@ -1789,6 +1811,9 @@ public void SetCallbacks(IGameplayActions instance) @Run.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRun; @Run.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRun; @Run.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRun; + @OpenDebugMenu.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnOpenDebugMenu; + @OpenDebugMenu.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnOpenDebugMenu; + @OpenDebugMenu.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnOpenDebugMenu; } m_Wrapper.m_GameplayActionsCallbackInterface = instance; if (instance != null) @@ -1820,6 +1845,9 @@ public void SetCallbacks(IGameplayActions instance) @Run.started += instance.OnRun; @Run.performed += instance.OnRun; @Run.canceled += instance.OnRun; + @OpenDebugMenu.started += instance.OnOpenDebugMenu; + @OpenDebugMenu.performed += instance.OnOpenDebugMenu; + @OpenDebugMenu.canceled += instance.OnOpenDebugMenu; } } } @@ -2014,6 +2042,7 @@ public interface IGameplayActions void OnRotateCamera(InputAction.CallbackContext context); void OnMouseControlCamera(InputAction.CallbackContext context); void OnRun(InputAction.CallbackContext context); + void OnOpenDebugMenu(InputAction.CallbackContext context); } public interface IMenusActions { diff --git a/UOP1_Project/Assets/Scripts/Input/InputReader.cs b/UOP1_Project/Assets/Scripts/Input/InputReader.cs index 2e6ce06bd2..474194ecf7 100644 --- a/UOP1_Project/Assets/Scripts/Input/InputReader.cs +++ b/UOP1_Project/Assets/Scripts/Input/InputReader.cs @@ -22,6 +22,7 @@ public class InputReader : ScriptableObject, GameInput.IGameplayActions, GameInp public event UnityAction disableMouseControlCameraEvent = delegate { }; public event UnityAction startedRunning = delegate { }; public event UnityAction stoppedRunning = delegate { }; + public event UnityAction openDebugMenu = delegate { }; // Shared between menus and dialogues public event UnityAction moveSelectionEvent = delegate { }; @@ -155,6 +156,12 @@ public void OnMouseControlCamera(InputAction.CallbackContext context) disableMouseControlCameraEvent.Invoke(); } + public void OnOpenDebugMenu(InputAction.CallbackContext context) + { + if (context.phase == InputActionPhase.Performed) + openDebugMenu.Invoke(); + } + private bool IsDeviceMouse(InputAction.CallbackContext context) => context.control.device.name == "Mouse"; public void OnMoveSelection(InputAction.CallbackContext context) diff --git a/UOP1_Project/Assets/Settings/Input/GameInput.inputactions b/UOP1_Project/Assets/Settings/Input/GameInput.inputactions index b1b4a977c4..edae90275a 100644 --- a/UOP1_Project/Assets/Settings/Input/GameInput.inputactions +++ b/UOP1_Project/Assets/Settings/Input/GameInput.inputactions @@ -76,6 +76,14 @@ "expectedControlType": "Button", "processors": "", "interactions": "" + }, + { + "name": "OpenDebugMenu", + "type": "Button", + "id": "01cc35a0-576f-4d88-9bd1-7de987c51f52", + "expectedControlType": "Button", + "processors": "", + "interactions": "" } ], "bindings": [ @@ -474,6 +482,17 @@ "action": "Run", "isComposite": false, "isPartOfComposite": false + }, + { + "name": "", + "id": "fa641624-9abb-4037-b855-92c4f1c79f94", + "path": "/backquote", + "interactions": "", + "processors": "", + "groups": "KeyboardOrGamepad", + "action": "OpenDebugMenu", + "isComposite": false, + "isPartOfComposite": false } ] }, From 5696a123621ea5168eb65c615a73ee4d3203cffe Mon Sep 17 00:00:00 2001 From: Harsh Narayan Jha <50262541+HarshNarayanJha@users.noreply.github.com> Date: Mon, 2 Aug 2021 19:22:44 +0530 Subject: [PATCH 2/9] Create DebugConfigSO --- .../Assets/ScriptableObjects/DebugSystem.meta | 8 ++++++ .../DebugSystem/DebugConfigSO.asset | 25 +++++++++++++++++++ .../DebugSystem/DebugConfigSO.asset.meta | 8 ++++++ UOP1_Project/Assets/Scripts/DebugSystem.meta | 8 ++++++ .../Scripts/DebugSystem/DebugConfigSO.cs | 9 +++++++ .../Scripts/DebugSystem/DebugConfigSO.cs.meta | 11 ++++++++ 6 files changed, 69 insertions(+) create mode 100644 UOP1_Project/Assets/ScriptableObjects/DebugSystem.meta create mode 100644 UOP1_Project/Assets/ScriptableObjects/DebugSystem/DebugConfigSO.asset create mode 100644 UOP1_Project/Assets/ScriptableObjects/DebugSystem/DebugConfigSO.asset.meta create mode 100644 UOP1_Project/Assets/Scripts/DebugSystem.meta create mode 100644 UOP1_Project/Assets/Scripts/DebugSystem/DebugConfigSO.cs create mode 100644 UOP1_Project/Assets/Scripts/DebugSystem/DebugConfigSO.cs.meta diff --git a/UOP1_Project/Assets/ScriptableObjects/DebugSystem.meta b/UOP1_Project/Assets/ScriptableObjects/DebugSystem.meta new file mode 100644 index 0000000000..13b44f2232 --- /dev/null +++ b/UOP1_Project/Assets/ScriptableObjects/DebugSystem.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c09857cfb2f81ef48b88acf5fa3a8913 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UOP1_Project/Assets/ScriptableObjects/DebugSystem/DebugConfigSO.asset b/UOP1_Project/Assets/ScriptableObjects/DebugSystem/DebugConfigSO.asset new file mode 100644 index 0000000000..0041973242 --- /dev/null +++ b/UOP1_Project/Assets/ScriptableObjects/DebugSystem/DebugConfigSO.asset @@ -0,0 +1,25 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: eb002a5998fe63a46ba662062deb4e34, type: 3} + m_Name: DebugConfigSO + m_EditorClassIdentifier: + locations: + - {fileID: 11400000, guid: 2f386bbc670c05145834a0f9c7d55798, type: 2} + - {fileID: 11400000, guid: 3902a4362b3a4fb4ab5ce5dcc07d8427, type: 2} + - {fileID: 11400000, guid: 5c64917a0d7e83242b5e7f5722ec1b85, type: 2} + - {fileID: 11400000, guid: 57fc3dc5008bccc48a36cfc0e7fbcaaf, type: 2} + - {fileID: 11400000, guid: 225926d1405c84f4399317b70b0e94b7, type: 2} + - {fileID: 11400000, guid: 0d5b48391ae82cb4aaeea96320eecaad, type: 2} + - {fileID: 11400000, guid: 5d1995624f58d0a47b8ef6a95f7d1292, type: 2} + - {fileID: 11400000, guid: d102ba8fe3b291249aeb9de4b95c1904, type: 2} + - {fileID: 11400000, guid: 23c02ca61c99f4244854ea282a8b86f0, type: 2} + - {fileID: 11400000, guid: dcbe64c23ef61994a9b02173b073d5dc, type: 2} diff --git a/UOP1_Project/Assets/ScriptableObjects/DebugSystem/DebugConfigSO.asset.meta b/UOP1_Project/Assets/ScriptableObjects/DebugSystem/DebugConfigSO.asset.meta new file mode 100644 index 0000000000..3454734cb3 --- /dev/null +++ b/UOP1_Project/Assets/ScriptableObjects/DebugSystem/DebugConfigSO.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 26655c6f12c6ab747a6fbec88040485a +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/UOP1_Project/Assets/Scripts/DebugSystem.meta b/UOP1_Project/Assets/Scripts/DebugSystem.meta new file mode 100644 index 0000000000..75f108f500 --- /dev/null +++ b/UOP1_Project/Assets/Scripts/DebugSystem.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f1dca90e47ed852429d5d4eb866729c4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UOP1_Project/Assets/Scripts/DebugSystem/DebugConfigSO.cs b/UOP1_Project/Assets/Scripts/DebugSystem/DebugConfigSO.cs new file mode 100644 index 0000000000..28ff0c83e3 --- /dev/null +++ b/UOP1_Project/Assets/Scripts/DebugSystem/DebugConfigSO.cs @@ -0,0 +1,9 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[CreateAssetMenu(fileName = "NewDebugConfigSO", menuName = "Debug/Debug Config")] +public class DebugConfigSO : ScriptableObject +{ + public LocationSO[] locations; +} diff --git a/UOP1_Project/Assets/Scripts/DebugSystem/DebugConfigSO.cs.meta b/UOP1_Project/Assets/Scripts/DebugSystem/DebugConfigSO.cs.meta new file mode 100644 index 0000000000..e4b0771d69 --- /dev/null +++ b/UOP1_Project/Assets/Scripts/DebugSystem/DebugConfigSO.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: eb002a5998fe63a46ba662062deb4e34 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From e36c50bb0b7ddf9510a6f2bbdf53685c90ec4de2 Mon Sep 17 00:00:00 2001 From: Harsh Narayan Jha <50262541+HarshNarayanJha@users.noreply.github.com> Date: Mon, 2 Aug 2021 19:23:13 +0530 Subject: [PATCH 3/9] Created UIDebug --- .../Assets/Scripts/DebugSystem/UIDebug.cs | 44 +++++++++++++++++++ .../Scripts/DebugSystem/UIDebug.cs.meta | 11 +++++ 2 files changed, 55 insertions(+) create mode 100644 UOP1_Project/Assets/Scripts/DebugSystem/UIDebug.cs create mode 100644 UOP1_Project/Assets/Scripts/DebugSystem/UIDebug.cs.meta diff --git a/UOP1_Project/Assets/Scripts/DebugSystem/UIDebug.cs b/UOP1_Project/Assets/Scripts/DebugSystem/UIDebug.cs new file mode 100644 index 0000000000..36a30c0b59 --- /dev/null +++ b/UOP1_Project/Assets/Scripts/DebugSystem/UIDebug.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; +using TMPro; +using UnityEngine.Events; + +public class UIDebug : MonoBehaviour +{ + [SerializeField] private DebugConfigSO debugConfig; + [SerializeField] private Button[] locationButtons; + [SerializeField] private GameObject buttonPrefab; + [SerializeField] private GameObject locationsParent; + + public UnityAction buttonClickAction; + + public UnityAction Closed; + + + private void Start() + { + locationButtons = new Button[debugConfig.locations.Length]; + + for (int i = 0; i < debugConfig.locations.Length; i++) + { + GameObject locationButton = Instantiate(buttonPrefab); + locationButton.name = "Location Item " + i; + locationButton.transform.SetParent(locationsParent.gameObject.transform, false); + + TextMeshProUGUI text = locationButton.transform.GetChild(0).GetComponent(); + text.SetText(debugConfig.locations[i].name); + + + //Debug.Log(i); + locationButtons[i] = locationButton.GetComponent