From 1cbdbba086a577aca62bcd28a5878ccba4e03f2d Mon Sep 17 00:00:00 2001 From: minenice55 Date: Sat, 6 Jan 2024 22:56:02 -0500 Subject: [PATCH] sanity checks in controller shit (#611) --- Assets/Scripts/InputSystem/PlayerInput.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/InputSystem/PlayerInput.cs b/Assets/Scripts/InputSystem/PlayerInput.cs index 6e29de66..f8668236 100644 --- a/Assets/Scripts/InputSystem/PlayerInput.cs +++ b/Assets/Scripts/InputSystem/PlayerInput.cs @@ -47,7 +47,7 @@ namespace HeavenStudio public static InputController.ControlStyles CurrentControlStyle = InputController.ControlStyles.Pad; - static List inputDevices; + static List inputDevices = new List(); public delegate InputController[] InputControllerInitializer(); @@ -126,6 +126,7 @@ namespace HeavenStudio //so such controllers should have a reference to the other controller in the pair foreach (InputController i in inputDevices) { + if (i == null) continue; if (i.GetPlayer() == player) { return i; @@ -142,6 +143,7 @@ namespace HeavenStudio //controller IDs are determined by connection order (the Keyboard is always first) for (int i = 0; i < inputDevices.Count; i++) { + if (inputDevices[i] == null) continue; if (inputDevices[i].GetPlayer() == player) { return i; @@ -152,8 +154,10 @@ namespace HeavenStudio public static void UpdateInputControllers() { + if (inputDevices == null) return; foreach (InputController i in inputDevices) { + if (i == null) continue; i.UpdateState(); } }