Skip to content
Snippets Groups Projects
Commit 951ec3cc authored by Heine, Eric R's avatar Heine, Eric R
Browse files

Added game event loggers for the four types of basic value game events.

parent 4d39151b
No related branches found
No related tags found
1 merge request!3Merge Request for Issue/3 Added game event loggers for the four types of basic value game events.
using UnityEngine;
using Shared.ScriptableVariables;
namespace Shared.EventLog {
// Logs a boolean game event when it is raised
// Depends on ScriptableVariable package
public class BooleanGameEventLogger : BooleanGameEventListener {
[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(bool value) {
eventLog.Add(string.IsNullOrEmpty(customKey) ? $"{eventToListenTo.name} Triggered" : customKey, !string.IsNullOrEmpty(customValueFormat) ? string.Format(customValueFormat, value) : value.ToString());
base.OnEventRaised(value);
}
}
}
fileFormatVersion: 2
guid: 8e522c9f678eaa648a263ea5e6919776
timeCreated: 1510685488
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
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);
}
}
}
fileFormatVersion: 2
guid: 5e790628a507f5d449c58dc70a429127
timeCreated: 1510685488
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -7,11 +7,15 @@ namespace Shared.EventLog {
public class GameEventLogger : GameEventListener {
[Tooltip("The event log to add the event trigger log to")]
public EventLog eventLog;
[Tooltip("The custom key to use in the event log")]
public string customKey;
[Tooltip("The custom value to use in the event log")]
public string customValue;
//---------------------------------------------------------------------------
// Overridden event listening function to add the event to the event log
public override void OnEventRaised() {
eventLog.Add(eventToListenTo.name + " Triggered", "");
eventLog.Add(string.IsNullOrEmpty(customKey) ? $"{eventToListenTo.name} Triggered" : customKey, string.IsNullOrEmpty(customValue) ? "" : customValue);
base.OnEventRaised();
}
}
......
using UnityEngine;
using Shared.ScriptableVariables;
namespace Shared.EventLog {
// Logs a int game event when it is raised
// Depends on ScriptableVariable package
public class IntGameEventLogger : IntGameEventListener {
[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(int value) {
eventLog.Add(string.IsNullOrEmpty(customKey) ? $"{eventToListenTo.name} Triggered" : customKey, !string.IsNullOrEmpty(customValueFormat) ? string.Format(customValueFormat, value) : value.ToString());
base.OnEventRaised(value);
}
}
}
fileFormatVersion: 2
guid: 21cd7582d990fe44a9d0987067a01d07
timeCreated: 1510685488
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using Shared.ScriptableVariables;
namespace Shared.EventLog {
// Logs a string game event when it is raised
// Depends on ScriptableVariable package
public class StringGameEventLogger : StringGameEventListener {
[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(string value) {
eventLog.Add(string.IsNullOrEmpty(customKey) ? $"{eventToListenTo.name} Triggered" : customKey, !string.IsNullOrEmpty(customValueFormat) ? string.Format(customValueFormat, value) : value);
base.OnEventRaised(value);
}
}
}
fileFormatVersion: 2
guid: 149bda40b8fd7124eb7f66dff5220467
timeCreated: 1510685488
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment