From fc2713ddcde7ec1d65634534a8b038ad46942c08 Mon Sep 17 00:00:00 2001 From: Christopher Date: Thu, 21 Jul 2016 16:51:10 +0100 Subject: [PATCH] Fixed dialog input causing an exception if no Event System is present. --- Assets/Fungus/Narrative/Scripts/DialogInput.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Assets/Fungus/Narrative/Scripts/DialogInput.cs b/Assets/Fungus/Narrative/Scripts/DialogInput.cs index 0f85bef3..c21fb713 100644 --- a/Assets/Fungus/Narrative/Scripts/DialogInput.cs +++ b/Assets/Fungus/Narrative/Scripts/DialogInput.cs @@ -83,7 +83,20 @@ namespace Fungus protected virtual void Update() { if (currentStandaloneInputModule == null) + { + if (EventSystem.current == null) + { + // Auto spawn an Event System from the prefab + GameObject prefab = Resources.Load("EventSystem"); + if (prefab != null) + { + GameObject go = Instantiate(prefab) as GameObject; + go.name = "EventSystem"; + } + } + currentStandaloneInputModule = EventSystem.current.GetComponent(); + } if (Input.GetButtonDown(currentStandaloneInputModule.submitButton) || (cancelEnabled && Input.GetButton(currentStandaloneInputModule.cancelButton)))