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

Added GameObject and Transform variables and events.

parent cd127b92
No related branches found
No related tags found
No related merge requests found
Showing
with 284 additions and 0 deletions
using UnityEditor;
using UnityEngine;
namespace Shared.ScriptableVariables {
//---------------------------------------------------------------------------
[CustomEditor(typeof(GameObjectGameEvent))]
public class GameObjectGameEventEditor : Editor {
private GameObject testValue;
//---------------------------------------------------------------------------
public override void OnInspectorGUI() {
base.OnInspectorGUI();
EditorGUILayout.BeginHorizontal();
testValue = (GameObject)EditorGUILayout.ObjectField("Test Value", testValue, typeof(GameObject), true);
if (GUILayout.Button("Fire Event")) {
((GameObjectGameEvent)target).Raise(testValue);
}
EditorGUILayout.EndHorizontal();
}
}
}
fileFormatVersion: 2
guid: ee6b1c586c9bea84d91372b244254de6
timeCreated: 1513206436
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEditor;
using UnityEngine;
namespace Shared.ScriptableVariables {
//---------------------------------------------------------------------------
[CustomEditor(typeof(TransformGameEvent))]
public class TransformGameEventEditor : Editor {
private Transform testValue;
//---------------------------------------------------------------------------
public override void OnInspectorGUI() {
base.OnInspectorGUI();
EditorGUILayout.BeginHorizontal();
testValue = (Transform)EditorGUILayout.ObjectField("Test Value", testValue, typeof(Transform), true);
if (GUILayout.Button("Fire Event")) {
((TransformGameEvent)target).Raise(testValue);
}
EditorGUILayout.EndHorizontal();
}
}
}
fileFormatVersion: 2
guid: b75f707cd7c69d84f94f5d8fab44e889
timeCreated: 1513206436
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
namespace Shared.ScriptableVariables {
// ScriptableVariable that decouples components firing and listening to game events that require a GameObject parameter
[CreateAssetMenu(menuName = "Scriptable Objects/Events/Game Object Game Event")]
public class GameObjectGameEvent : GameEvent<GameObject> {
}
}
fileFormatVersion: 2
guid: e04e52238d5e84e4993faf76d33b291a
timeCreated: 1510599448
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using UnityEngine.Events;
namespace Shared.ScriptableVariables {
[System.Serializable]
public class GameObjectUnityEvent : UnityEvent<GameObject> {}
}
fileFormatVersion: 2
guid: 3fbaadaeaab577a40b9d0873c6c11366
timeCreated: 1510599448
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
namespace Shared.ScriptableVariables {
// ScriptableVariable that decouples components firing and listening to game events that require a Transform parameter
[CreateAssetMenu(menuName = "Scriptable Objects/Events/Transform Game Event")]
public class TransformGameEvent : GameEvent<Transform> {
}
}
fileFormatVersion: 2
guid: 2dd5f4b25c226024d9804a115d9e40ab
timeCreated: 1510599448
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using UnityEngine.Events;
namespace Shared.ScriptableVariables {
[System.Serializable]
public class TransformUnityEvent : UnityEvent<Transform> {}
}
fileFormatVersion: 2
guid: d8e1417a02d399b4fa63148c4fad8c1b
timeCreated: 1510599448
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using UnityEngine.Events;
namespace Shared.ScriptableVariables {
// Component to tie GameObjectGameEvents to Unity's event system
public class GameObjectGameEventListener : GameEventListener<GameObject> {
[Tooltip("The game event to listen to")]
public GameObjectGameEvent eventToListenTo;
[Tooltip("The UnityEvent to raise in response to the game event being raised")]
public GameObjectUnityEvent response;
//---------------------------------------------------------------------------
protected override GameEvent<GameObject> GetGameEvent() { return eventToListenTo; }
//---------------------------------------------------------------------------
protected override UnityEvent<GameObject> GetUnityEvent() { return response; }
}
}
fileFormatVersion: 2
guid: 2b57c9ebe59f6504fb36be48323716e4
timeCreated: 1510599448
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using UnityEngine.Events;
namespace Shared.ScriptableVariables {
/// <summary>
/// Used to trigger a UnityEvent in response to changes on a GameObjectVariable
/// </summary>
public class GameObjectVariableListener : ScriptableVariableListener<GameObject> {
[Tooltip("The ScriptableVariable to listen for changes")]
public GameObjectVariable variable;
[Tooltip("The UnityEvent that gets triggered when the variable changes value")]
public GameObjectUnityEvent OnValueChangedEvent;
//---------------------------------------------------------------------------
protected override ScriptableVariable<GameObject> GetScriptableVariable() { return variable; }
//---------------------------------------------------------------------------
protected override UnityEvent<GameObject> GetUnityEvent() { return OnValueChangedEvent; }
}
}
fileFormatVersion: 2
guid: be924a55a600ad143b48151781b6fb9f
timeCreated: 1513208270
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using UnityEngine.Events;
namespace Shared.ScriptableVariables {
// Component to tie TransformGameEvents to Unity's event system
public class TransformGameEventListener : GameEventListener<Transform> {
[Tooltip("The game event to listen to")]
public TransformGameEvent eventToListenTo;
[Tooltip("The UnityEvent to raise in response to the game event being raised")]
public TransformUnityEvent response;
//---------------------------------------------------------------------------
protected override GameEvent<Transform> GetGameEvent() { return eventToListenTo; }
//---------------------------------------------------------------------------
protected override UnityEvent<Transform> GetUnityEvent() { return response; }
}
}
fileFormatVersion: 2
guid: 2833a1a78d0f1ac488ac49c421fe28bb
timeCreated: 1510599448
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using UnityEngine.Events;
namespace Shared.ScriptableVariables {
/// <summary>
/// Used to trigger a UnityEvent in response to changes on a TransformVariable
/// </summary>
public class TransformVariableListener : ScriptableVariableListener<Transform> {
[Tooltip("The ScriptableVariable to listen for changes")]
public TransformVariable variable;
[Tooltip("The UnityEvent that gets triggered when the variable changes value")]
public TransformUnityEvent OnValueChangedEvent;
//---------------------------------------------------------------------------
protected override ScriptableVariable<Transform> GetScriptableVariable() { return variable; }
//---------------------------------------------------------------------------
protected override UnityEvent<Transform> GetUnityEvent() { return OnValueChangedEvent; }
}
}
fileFormatVersion: 2
guid: f80c99495055b6441b28767f1adb90fd
timeCreated: 1513208270
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