diff --git a/Scriptable Variables/Listeners/GameEventListener.cs b/Scriptable Variables/Listeners/GameEventListener.cs index 1c3e7e83447868789a878967c99663a5a26798d0..7c89bdf54fb16e96889116e386254c761be40557 100644 --- a/Scriptable Variables/Listeners/GameEventListener.cs +++ b/Scriptable Variables/Listeners/GameEventListener.cs @@ -1,4 +1,5 @@ -using UnityEngine; +using System; +using UnityEngine; using UnityEngine.Events; namespace Shared.ScriptableVariables { @@ -23,7 +24,13 @@ namespace Shared.ScriptableVariables { //--------------------------------------------------------------------------- public virtual void OnEventRaised() { if (response != null) { - response.Invoke(); + try { + response.Invoke(); + } + catch (Exception exception) { + Debug.LogError($"{gameObject.name} is throwing the following exception:"); + Debug.LogException(exception); + } } } } @@ -50,7 +57,13 @@ namespace Shared.ScriptableVariables { public virtual void OnEventRaised(T value) { var unityEvent = GetUnityEvent(); if (unityEvent != null) { - unityEvent.Invoke(value); + try { + unityEvent.Invoke(value); + } + catch (Exception exception) { + Debug.LogError($"{gameObject.name} is throwing the following exception:"); + Debug.LogException(exception); + } } } }