Browse Source

Fixed dialog input causing an exception if no Event System is present.

master
Christopher 8 years ago
parent
commit
fc2713ddcd
  1. 13
      Assets/Fungus/Narrative/Scripts/DialogInput.cs

13
Assets/Fungus/Narrative/Scripts/DialogInput.cs

@ -83,7 +83,20 @@ namespace Fungus
protected virtual void Update() protected virtual void Update()
{ {
if (currentStandaloneInputModule == null) if (currentStandaloneInputModule == null)
{
if (EventSystem.current == null)
{
// Auto spawn an Event System from the prefab
GameObject prefab = Resources.Load<GameObject>("EventSystem");
if (prefab != null)
{
GameObject go = Instantiate(prefab) as GameObject;
go.name = "EventSystem";
}
}
currentStandaloneInputModule = EventSystem.current.GetComponent<StandaloneInputModule>(); currentStandaloneInputModule = EventSystem.current.GetComponent<StandaloneInputModule>();
}
if (Input.GetButtonDown(currentStandaloneInputModule.submitButton) || if (Input.GetButtonDown(currentStandaloneInputModule.submitButton) ||
(cancelEnabled && Input.GetButton(currentStandaloneInputModule.cancelButton))) (cancelEnabled && Input.GetButton(currentStandaloneInputModule.cancelButton)))

Loading…
Cancel
Save