diff --git a/Scriptable Variables/Events/Editor/GameObjectGameEventEditor.cs b/Scriptable Variables/Events/Editor/GameObjectGameEventEditor.cs new file mode 100644 index 0000000000000000000000000000000000000000..4242e0b4f3f8a86c3fd74bf63784a25951f89930 --- /dev/null +++ b/Scriptable Variables/Events/Editor/GameObjectGameEventEditor.cs @@ -0,0 +1,22 @@ +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(); + } + } +} diff --git a/Scriptable Variables/Events/Editor/GameObjectGameEventEditor.cs.meta b/Scriptable Variables/Events/Editor/GameObjectGameEventEditor.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..9de633f522d974600c0ea2e1a62249d2912de93c --- /dev/null +++ b/Scriptable Variables/Events/Editor/GameObjectGameEventEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ee6b1c586c9bea84d91372b244254de6 +timeCreated: 1513206436 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scriptable Variables/Events/Editor/TransformGameEventEditor.cs b/Scriptable Variables/Events/Editor/TransformGameEventEditor.cs new file mode 100644 index 0000000000000000000000000000000000000000..4d6dbbcbf4a1bbc8946aef11364795c6a448c62d --- /dev/null +++ b/Scriptable Variables/Events/Editor/TransformGameEventEditor.cs @@ -0,0 +1,22 @@ +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(); + } + } +} diff --git a/Scriptable Variables/Events/Editor/TransformGameEventEditor.cs.meta b/Scriptable Variables/Events/Editor/TransformGameEventEditor.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..9603c53cfb3d7c200cfebf9c34a71d15ce8ee4b0 --- /dev/null +++ b/Scriptable Variables/Events/Editor/TransformGameEventEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b75f707cd7c69d84f94f5d8fab44e889 +timeCreated: 1513206436 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scriptable Variables/Events/GameObjectGameEvent.cs b/Scriptable Variables/Events/GameObjectGameEvent.cs new file mode 100644 index 0000000000000000000000000000000000000000..60ce26463a5263f0c1d47c147f18d3a24bb8bd33 --- /dev/null +++ b/Scriptable Variables/Events/GameObjectGameEvent.cs @@ -0,0 +1,8 @@ +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> { + } +} diff --git a/Scriptable Variables/Events/GameObjectGameEvent.cs.meta b/Scriptable Variables/Events/GameObjectGameEvent.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..8f1829166187956c939e099f7e8979df730192a8 --- /dev/null +++ b/Scriptable Variables/Events/GameObjectGameEvent.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: e04e52238d5e84e4993faf76d33b291a +timeCreated: 1510599448 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scriptable Variables/Events/GameObjectUnityEvent.cs b/Scriptable Variables/Events/GameObjectUnityEvent.cs new file mode 100644 index 0000000000000000000000000000000000000000..d17aaf9d9f002d384d68f0814466d41d120b1cfa --- /dev/null +++ b/Scriptable Variables/Events/GameObjectUnityEvent.cs @@ -0,0 +1,7 @@ +using UnityEngine; +using UnityEngine.Events; + +namespace Shared.ScriptableVariables { + [System.Serializable] + public class GameObjectUnityEvent : UnityEvent<GameObject> {} +} diff --git a/Scriptable Variables/Events/GameObjectUnityEvent.cs.meta b/Scriptable Variables/Events/GameObjectUnityEvent.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..5537a9dd68890579aa681ae74acfc74df6e27482 --- /dev/null +++ b/Scriptable Variables/Events/GameObjectUnityEvent.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 3fbaadaeaab577a40b9d0873c6c11366 +timeCreated: 1510599448 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scriptable Variables/Events/TransformGameEvent.cs b/Scriptable Variables/Events/TransformGameEvent.cs new file mode 100644 index 0000000000000000000000000000000000000000..f52317736deeef0cd9bf1ec4092b525adb0098f5 --- /dev/null +++ b/Scriptable Variables/Events/TransformGameEvent.cs @@ -0,0 +1,8 @@ +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> { + } +} diff --git a/Scriptable Variables/Events/TransformGameEvent.cs.meta b/Scriptable Variables/Events/TransformGameEvent.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..54f3618daeb2e18e27dd0f412b27a731ebca9735 --- /dev/null +++ b/Scriptable Variables/Events/TransformGameEvent.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 2dd5f4b25c226024d9804a115d9e40ab +timeCreated: 1510599448 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scriptable Variables/Events/TransformUnityEvent.cs b/Scriptable Variables/Events/TransformUnityEvent.cs new file mode 100644 index 0000000000000000000000000000000000000000..774a17b8394c04c660e2147b1332f00df01d3100 --- /dev/null +++ b/Scriptable Variables/Events/TransformUnityEvent.cs @@ -0,0 +1,7 @@ +using UnityEngine; +using UnityEngine.Events; + +namespace Shared.ScriptableVariables { + [System.Serializable] + public class TransformUnityEvent : UnityEvent<Transform> {} +} diff --git a/Scriptable Variables/Events/TransformUnityEvent.cs.meta b/Scriptable Variables/Events/TransformUnityEvent.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..79f555fd12b9842dea6ecc110f41467068eb0344 --- /dev/null +++ b/Scriptable Variables/Events/TransformUnityEvent.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: d8e1417a02d399b4fa63148c4fad8c1b +timeCreated: 1510599448 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scriptable Variables/Listeners/GameObjectGameEventListener.cs b/Scriptable Variables/Listeners/GameObjectGameEventListener.cs new file mode 100644 index 0000000000000000000000000000000000000000..e2fc36c8ff76bd263b1ba5be6c63f3264573854a --- /dev/null +++ b/Scriptable Variables/Listeners/GameObjectGameEventListener.cs @@ -0,0 +1,19 @@ +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; } + } +} diff --git a/Scriptable Variables/Listeners/GameObjectGameEventListener.cs.meta b/Scriptable Variables/Listeners/GameObjectGameEventListener.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..1b5bd5ee95d2253a1ae044e0a56e612e11e18bea --- /dev/null +++ b/Scriptable Variables/Listeners/GameObjectGameEventListener.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 2b57c9ebe59f6504fb36be48323716e4 +timeCreated: 1510599448 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scriptable Variables/Listeners/GameObjectVariableListener.cs b/Scriptable Variables/Listeners/GameObjectVariableListener.cs new file mode 100644 index 0000000000000000000000000000000000000000..0d9376c78555ab25db8286094ed8a79bbbf83031 --- /dev/null +++ b/Scriptable Variables/Listeners/GameObjectVariableListener.cs @@ -0,0 +1,21 @@ +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; } + } +} diff --git a/Scriptable Variables/Listeners/GameObjectVariableListener.cs.meta b/Scriptable Variables/Listeners/GameObjectVariableListener.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..691a2f5d968fd4bdf04e55ac5c949a9f690256f5 --- /dev/null +++ b/Scriptable Variables/Listeners/GameObjectVariableListener.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: be924a55a600ad143b48151781b6fb9f +timeCreated: 1513208270 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scriptable Variables/Listeners/TransformGameEventListener.cs b/Scriptable Variables/Listeners/TransformGameEventListener.cs new file mode 100644 index 0000000000000000000000000000000000000000..67402c88691d4e388675d3dede31ad8685172cc7 --- /dev/null +++ b/Scriptable Variables/Listeners/TransformGameEventListener.cs @@ -0,0 +1,19 @@ +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; } + } +} diff --git a/Scriptable Variables/Listeners/TransformGameEventListener.cs.meta b/Scriptable Variables/Listeners/TransformGameEventListener.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..ddbed7258c1d6f7310ccccda5483c45f7a616896 --- /dev/null +++ b/Scriptable Variables/Listeners/TransformGameEventListener.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 2833a1a78d0f1ac488ac49c421fe28bb +timeCreated: 1510599448 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scriptable Variables/Listeners/TransformVariableListener.cs b/Scriptable Variables/Listeners/TransformVariableListener.cs new file mode 100644 index 0000000000000000000000000000000000000000..be65b28301777eb46a998dc22939e68004862b93 --- /dev/null +++ b/Scriptable Variables/Listeners/TransformVariableListener.cs @@ -0,0 +1,21 @@ +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; } + } +} diff --git a/Scriptable Variables/Listeners/TransformVariableListener.cs.meta b/Scriptable Variables/Listeners/TransformVariableListener.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..a9bf1b8dfa3617e22247937c0a5d176cefd5a396 --- /dev/null +++ b/Scriptable Variables/Listeners/TransformVariableListener.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: f80c99495055b6441b28767f1adb90fd +timeCreated: 1513208270 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scriptable Variables/Variables/Base Types/GameObjectVariable.cs b/Scriptable Variables/Variables/Base Types/GameObjectVariable.cs new file mode 100644 index 0000000000000000000000000000000000000000..53887f337ed590ba194af32de3f3c29d94789d91 --- /dev/null +++ b/Scriptable Variables/Variables/Base Types/GameObjectVariable.cs @@ -0,0 +1,21 @@ +using UnityEngine; + +namespace Shared.ScriptableVariables { + // A GameObject value to share across components, scenes, and prefabs + [CreateAssetMenu(menuName = "Scriptable Objects/Variables/GameObject")] + public class GameObjectVariable : ScriptableVariable<GameObject> { + //--------------------------------------------------------------------------- + [ContextMenu("Reset To Default Value")] + public void ContextMenuReset() { + Reset(); + } + } + +#if UNITY_EDITOR + //----------------------------------------------------------------------------- + [UnityEditor.CustomEditor(typeof(GameObjectVariable))] + [UnityEditor.CanEditMultipleObjects] + public class GameObjectScriptableVariableEditor : GameObjectVariable.BaseScriptableVariableEditor { + } +#endif +} diff --git a/Scriptable Variables/Variables/Base Types/GameObjectVariable.cs.meta b/Scriptable Variables/Variables/Base Types/GameObjectVariable.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..ba133dae0c5514efb1070f9a63ac6993e68fac98 --- /dev/null +++ b/Scriptable Variables/Variables/Base Types/GameObjectVariable.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ad701a5d8d1a01545bdb29c2209badba +timeCreated: 1510599427 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scriptable Variables/Variables/Base Types/TransformVariable.cs b/Scriptable Variables/Variables/Base Types/TransformVariable.cs new file mode 100644 index 0000000000000000000000000000000000000000..75a81b99a0aa77b0f89161ea68959ab848476b44 --- /dev/null +++ b/Scriptable Variables/Variables/Base Types/TransformVariable.cs @@ -0,0 +1,21 @@ +using UnityEngine; + +namespace Shared.ScriptableVariables { + // A Transform value to share across components, scenes, and prefabs + [CreateAssetMenu(menuName = "Scriptable Objects/Variables/Transform")] + public class TransformVariable : ScriptableVariable<Transform> { + //--------------------------------------------------------------------------- + [ContextMenu("Reset To Default Value")] + public void ContextMenuReset() { + Reset(); + } + } + +#if UNITY_EDITOR + //----------------------------------------------------------------------------- + [UnityEditor.CustomEditor(typeof(TransformVariable))] + [UnityEditor.CanEditMultipleObjects] + public class TransformScriptableVariableEditor : TransformVariable.BaseScriptableVariableEditor { + } +#endif +} diff --git a/Scriptable Variables/Variables/Base Types/TransformVariable.cs.meta b/Scriptable Variables/Variables/Base Types/TransformVariable.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..415fbcc70bb40ba6a856953102644cd3020eb7ea --- /dev/null +++ b/Scriptable Variables/Variables/Base Types/TransformVariable.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 8700b7cc1b8f2214681e7d46f5703b2c +timeCreated: 1510599427 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scriptable Variables/Variables/Reference Types/ReferenceGameObjectVariable.cs b/Scriptable Variables/Variables/Reference Types/ReferenceGameObjectVariable.cs new file mode 100644 index 0000000000000000000000000000000000000000..bd25df16c0887e7fc07da40c6febd34e49acadcc --- /dev/null +++ b/Scriptable Variables/Variables/Reference Types/ReferenceGameObjectVariable.cs @@ -0,0 +1,8 @@ +using UnityEngine; + +namespace Shared.ScriptableVariables { + // A reference to a GameObject value to share across components, scenes, and prefabs that can be overridden to a constant different value + [CreateAssetMenu(menuName = "Scriptable Objects/Variables/Reference/GameObject")] + public class ReferenceGameObjectVariable : ReferenceScriptableVariable<GameObjectVariable, GameObject> { + } +} diff --git a/Scriptable Variables/Variables/Reference Types/ReferenceGameObjectVariable.cs.meta b/Scriptable Variables/Variables/Reference Types/ReferenceGameObjectVariable.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..a91680e4c734d1d9958999f96d621463e8d83a62 --- /dev/null +++ b/Scriptable Variables/Variables/Reference Types/ReferenceGameObjectVariable.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 2888fafc5d5b0224fae3f26946e440a1 +timeCreated: 1510599427 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scriptable Variables/Variables/Reference Types/ReferenceTransformVariable.cs b/Scriptable Variables/Variables/Reference Types/ReferenceTransformVariable.cs new file mode 100644 index 0000000000000000000000000000000000000000..da7e45c4a7d5152e8c32413358984247ac36a31e --- /dev/null +++ b/Scriptable Variables/Variables/Reference Types/ReferenceTransformVariable.cs @@ -0,0 +1,8 @@ +using UnityEngine; + +namespace Shared.ScriptableVariables { + // A reference to a Transform value to share across components, scenes, and prefabs that can be overridden to a constant different value + [CreateAssetMenu(menuName = "Scriptable Objects/Variables/Reference/Transform")] + public class ReferenceTransformVariable : ReferenceScriptableVariable<TransformVariable, Transform> { + } +} diff --git a/Scriptable Variables/Variables/Reference Types/ReferenceTransformVariable.cs.meta b/Scriptable Variables/Variables/Reference Types/ReferenceTransformVariable.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..3fc5f463f337278b1e61f6c23a867688ecb77f2a --- /dev/null +++ b/Scriptable Variables/Variables/Reference Types/ReferenceTransformVariable.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 8d74a6bcf7404ac4d88d067b2a9e4868 +timeCreated: 1510599427 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: