using UnityEngine; using Shared.ScriptableVariables; namespace Shared.EventLog { // Logs a float game event when it is raised // Depends on ScriptableVariable package public class FloatGameEventLogger : FloatGameEventListener { [Tooltip("The event log to add the event trigger log to")] public EventLog eventLog; [Tooltip("The custom key to use in the event log (if not set, the key will be the event name itself)")] public string customKey; [Tooltip("The custom format of the event value output (if not set, the value will be the ToString() of the value)")] public string customValueFormat; //--------------------------------------------------------------------------- // Overridden event listening function to add the event to the event log public override void OnEventRaised(float value) { eventLog.Add(string.IsNullOrEmpty(customKey) ? $"{eventToListenTo.name} Triggered" : customKey, !string.IsNullOrEmpty(customValueFormat) ? string.Format(customValueFormat, value) : value.ToString()); base.OnEventRaised(value); } } }