Ken Schaefer
5 years ago
29 changed files with 601 additions and 2 deletions
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 3c99d607772ce4347be90c8a91b9ebbb |
||||
folderAsset: yes |
||||
DefaultImporter: |
||||
externalObjects: {} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 4535e4d344da0844dac2544e46e61ccc |
||||
folderAsset: yes |
||||
DefaultImporter: |
||||
externalObjects: {} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,15 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Threading.Tasks; |
||||
using UnityEngine; |
||||
|
||||
namespace Architecture.Enums |
||||
{ |
||||
[CreateAssetMenu(fileName = "New Enum Value", menuName = "Architecture/Enum Value")] |
||||
public class EnumValue : ScriptableObject |
||||
{ |
||||
public string Name; |
||||
} |
||||
} |
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 97a3dd7294f44774184523763afc89ca |
||||
MonoImporter: |
||||
externalObjects: {} |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 7e005abc2b02b7f4eaf6a213a6077126 |
||||
folderAsset: yes |
||||
DefaultImporter: |
||||
externalObjects: {} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 93c4e8e5652153c468c80377a80cb93d |
||||
folderAsset: yes |
||||
DefaultImporter: |
||||
externalObjects: {} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,20 @@
|
||||
using UnityEditor; |
||||
using UnityEngine; |
||||
|
||||
namespace Architecture.Events |
||||
{ |
||||
[CustomEditor(typeof(GameEvent))] |
||||
public class EventEditor : Editor |
||||
{ |
||||
public override void OnInspectorGUI() |
||||
{ |
||||
base.OnInspectorGUI(); |
||||
|
||||
GUI.enabled = Application.isPlaying; |
||||
|
||||
GameEvent e = target as GameEvent; |
||||
if (GUILayout.Button("Raise")) |
||||
e.Raise(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 8564e34357d4a224a838d71bdb631b0c |
||||
timeCreated: 1506793093 |
||||
licenseType: Pro |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,48 @@
|
||||
// ---------------------------------------------------------------------------- |
||||
// Unite 2017 - Game Architecture with Scriptable Objects |
||||
// |
||||
// Author: Ryan Hipple |
||||
// Date: 10/04/17 |
||||
// ---------------------------------------------------------------------------- |
||||
|
||||
/****************************************************************************** |
||||
* Note from me: |
||||
* If you have not watched this presentation, drop everything and watch it now |
||||
* https://youtu.be/raQ3iHhE_Kk |
||||
* |
||||
* YOU MUST MASTER THIS CONTENT! |
||||
*****************************************************************************/ |
||||
|
||||
using System.Collections.Generic; |
||||
using UnityEngine; |
||||
|
||||
namespace Architecture.Events |
||||
{ |
||||
[CreateAssetMenu(fileName = "New Game Event", menuName = "Architecture/Game Event", order = 1)] |
||||
public class GameEvent : ScriptableObject |
||||
{ |
||||
/// <summary> |
||||
/// The list of listeners that this event will notify if it is raised. |
||||
/// </summary> |
||||
private readonly List<GameEventListener> eventListeners = |
||||
new List<GameEventListener>(); |
||||
|
||||
public void Raise() |
||||
{ |
||||
for (int i = eventListeners.Count - 1; i >= 0; i--) |
||||
eventListeners[i].OnEventRaised(); |
||||
} |
||||
|
||||
public void RegisterListener(GameEventListener listener) |
||||
{ |
||||
if (!eventListeners.Contains(listener)) |
||||
eventListeners.Add(listener); |
||||
} |
||||
|
||||
public void UnregisterListener(GameEventListener listener) |
||||
{ |
||||
if (eventListeners.Contains(listener)) |
||||
eventListeners.Remove(listener); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 1f3bbdb45cfb90548ae20b51284bb3ed |
||||
MonoImporter: |
||||
externalObjects: {} |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,45 @@
|
||||
// ---------------------------------------------------------------------------- |
||||
// Unite 2017 - Game Architecture with Scriptable Objects |
||||
// |
||||
// Author: Ryan Hipple |
||||
// Date: 10/04/17 |
||||
// ---------------------------------------------------------------------------- |
||||
|
||||
/****************************************************************************** |
||||
* Note from me: |
||||
* If you have not watched this presentation, drop everything and watch it now |
||||
* https://youtu.be/raQ3iHhE_Kk |
||||
* |
||||
* YOU MUST MASTER THIS CONTENT! |
||||
*****************************************************************************/ |
||||
|
||||
using UnityEngine; |
||||
using UnityEngine.Events; |
||||
|
||||
|
||||
namespace Architecture.Events |
||||
{ |
||||
public class GameEventListener : MonoBehaviour |
||||
{ |
||||
[Tooltip("Event to register with.")] |
||||
public GameEvent Event; |
||||
|
||||
[Tooltip("Response to invoke when Event is raised.")] |
||||
public UnityEvent Response; |
||||
|
||||
private void OnEnable() |
||||
{ |
||||
Event.RegisterListener(this); |
||||
} |
||||
|
||||
private void OnDisable() |
||||
{ |
||||
Event.UnregisterListener(this); |
||||
} |
||||
|
||||
public void OnEventRaised() |
||||
{ |
||||
Response.Invoke(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 6db0e2471827ae743b18e930d1a025dc |
||||
MonoImporter: |
||||
externalObjects: {} |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: d24ebc2f864c32f47abd7739a250bedd |
||||
folderAsset: yes |
||||
DefaultImporter: |
||||
externalObjects: {} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,38 @@
|
||||
// ---------------------------------------------------------------------------- |
||||
// Unite 2017 - Game Architecture with Scriptable Objects |
||||
// |
||||
// Author: Ryan Hipple |
||||
// Date: 10/04/17 |
||||
// ---------------------------------------------------------------------------- |
||||
|
||||
/****************************************************************************** |
||||
* Note from me: |
||||
* If you have not watched this presentation, drop everything and watch it now |
||||
* https://youtu.be/raQ3iHhE_Kk |
||||
* |
||||
* YOU MUST MASTER THIS CONTENT! |
||||
*****************************************************************************/ |
||||
|
||||
using UnityEngine; |
||||
|
||||
namespace Architecture.Variables |
||||
{ |
||||
[CreateAssetMenu(fileName = "New Boolean Variable", menuName = "Architecture/Boolean Variable")] |
||||
public class BoolVariable : ScriptableObject |
||||
{ |
||||
#if UNITY_EDITOR |
||||
[Multiline] |
||||
public string DeveloperDescription = ""; |
||||
#endif |
||||
|
||||
[SerializeField] |
||||
private bool value = false; |
||||
|
||||
public bool Value |
||||
{ |
||||
get { return value; } |
||||
set { this.value = value; } |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 4d056a20c5b6bba48b50aa8bcc2993d7 |
||||
MonoImporter: |
||||
externalObjects: {} |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: f768077bb3d9eed4aa5a935b516fa366 |
||||
folderAsset: yes |
||||
DefaultImporter: |
||||
externalObjects: {} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,77 @@
|
||||
// ---------------------------------------------------------------------------- |
||||
// Unite 2017 - Game Architecture with Scriptable Objects |
||||
// |
||||
// Author: Ryan Hipple |
||||
// Date: 10/04/17 |
||||
// ---------------------------------------------------------------------------- |
||||
|
||||
/****************************************************************************** |
||||
* Note from me: |
||||
* If you have not watched this presentation, drop everything and watch it now |
||||
* https://youtu.be/raQ3iHhE_Kk |
||||
* |
||||
* YOU MUST MASTER THIS CONTENT! |
||||
*****************************************************************************/ |
||||
|
||||
using UnityEditor; |
||||
using UnityEngine; |
||||
|
||||
namespace Architecture.Variables |
||||
{ |
||||
[CustomPropertyDrawer(typeof(FloatReference))] |
||||
public class FloatReferenceDrawer : PropertyDrawer |
||||
{ |
||||
/// <summary> |
||||
/// Options to display in the popup to select constant or variable. |
||||
/// </summary> |
||||
private readonly string[] popupOptions = |
||||
{ "Use Constant", "Use Variable" }; |
||||
|
||||
/// <summary> Cached style to use to draw the popup button. </summary> |
||||
private GUIStyle popupStyle; |
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) |
||||
{ |
||||
if (popupStyle == null) |
||||
{ |
||||
popupStyle = new GUIStyle(GUI.skin.GetStyle("PaneOptions")); |
||||
popupStyle.imagePosition = ImagePosition.ImageOnly; |
||||
} |
||||
|
||||
label = EditorGUI.BeginProperty(position, label, property); |
||||
position = EditorGUI.PrefixLabel(position, label); |
||||
|
||||
EditorGUI.BeginChangeCheck(); |
||||
|
||||
// Get properties |
||||
SerializedProperty useConstant = property.FindPropertyRelative("UseConstant"); |
||||
SerializedProperty constantValue = property.FindPropertyRelative("ConstantValue"); |
||||
SerializedProperty variable = property.FindPropertyRelative("Variable"); |
||||
|
||||
// Calculate rect for configuration button |
||||
Rect buttonRect = new Rect(position); |
||||
buttonRect.yMin += popupStyle.margin.top; |
||||
buttonRect.width = popupStyle.fixedWidth + popupStyle.margin.right; |
||||
position.xMin = buttonRect.xMax; |
||||
|
||||
// Store old indent level and set it to 0, the PrefixLabel takes care of it |
||||
int indent = EditorGUI.indentLevel; |
||||
EditorGUI.indentLevel = 0; |
||||
|
||||
int result = EditorGUI.Popup(buttonRect, useConstant.boolValue ? 0 : 1, popupOptions, popupStyle); |
||||
|
||||
useConstant.boolValue = result == 0; |
||||
|
||||
EditorGUI.PropertyField(position, |
||||
useConstant.boolValue ? constantValue : variable, |
||||
GUIContent.none); |
||||
|
||||
if (EditorGUI.EndChangeCheck()) |
||||
property.serializedObject.ApplyModifiedProperties(); |
||||
|
||||
EditorGUI.indentLevel = indent; |
||||
EditorGUI.EndProperty(); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2 |
||||
guid: d1339393180531047aef724fdc6f0f74 |
||||
MonoImporter: |
||||
externalObjects: {} |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,47 @@
|
||||
// ---------------------------------------------------------------------------- |
||||
// Unite 2017 - Game Architecture with Scriptable Objects |
||||
// |
||||
// Author: Ryan Hipple |
||||
// Date: 10/04/17 |
||||
// ---------------------------------------------------------------------------- |
||||
|
||||
/****************************************************************************** |
||||
* Note from me: |
||||
* If you have not watched this presentation, drop everything and watch it now |
||||
* https://youtu.be/raQ3iHhE_Kk |
||||
* |
||||
* YOU MUST MASTER THIS CONTENT! |
||||
*****************************************************************************/ |
||||
|
||||
using System; |
||||
|
||||
namespace Architecture.Variables |
||||
{ |
||||
[Serializable] |
||||
public class FloatReference |
||||
{ |
||||
public bool UseConstant = true; |
||||
public float ConstantValue; |
||||
public FloatVariable Variable; |
||||
|
||||
public FloatReference() |
||||
{ } |
||||
|
||||
public FloatReference(float value) |
||||
{ |
||||
UseConstant = true; |
||||
ConstantValue = value; |
||||
} |
||||
|
||||
public float Value |
||||
{ |
||||
get { return UseConstant ? ConstantValue : Variable.Value; } |
||||
} |
||||
|
||||
public static implicit operator float(FloatReference reference) |
||||
{ |
||||
return reference.Value; |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2 |
||||
guid: c02f17a3496c0f747b66a060639cc478 |
||||
MonoImporter: |
||||
externalObjects: {} |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,50 @@
|
||||
// ---------------------------------------------------------------------------- |
||||
// Unite 2017 - Game Architecture with Scriptable Objects |
||||
// |
||||
// Author: Ryan Hipple |
||||
// Date: 10/04/17 |
||||
// ---------------------------------------------------------------------------- |
||||
|
||||
/****************************************************************************** |
||||
* Note from me: |
||||
* If you have not watched this presentation, drop everything and watch it now |
||||
* https://youtu.be/raQ3iHhE_Kk |
||||
* |
||||
* YOU MUST MASTER THIS CONTENT! |
||||
*****************************************************************************/ |
||||
|
||||
using UnityEngine; |
||||
|
||||
namespace Architecture.Variables |
||||
{ |
||||
[CreateAssetMenu(fileName = "New Float Variable", menuName = "Architecture/Float Variable")] |
||||
public class FloatVariable : ScriptableObject |
||||
{ |
||||
#if UNITY_EDITOR |
||||
[Multiline] |
||||
public string DeveloperDescription = ""; |
||||
#endif |
||||
public float Value; |
||||
|
||||
public void SetValue(float value) |
||||
{ |
||||
Value = value; |
||||
} |
||||
|
||||
public void SetValue(FloatVariable value) |
||||
{ |
||||
Value = value.Value; |
||||
} |
||||
|
||||
public void ApplyChange(float amount) |
||||
{ |
||||
Value += amount; |
||||
} |
||||
|
||||
public void ApplyChange(FloatVariable amount) |
||||
{ |
||||
Value += amount.Value; |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 7cb18c6bb3c4bcd40b8451100e11b136 |
||||
MonoImporter: |
||||
externalObjects: {} |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,50 @@
|
||||
// ---------------------------------------------------------------------------- |
||||
// Unite 2017 - Game Architecture with Scriptable Objects |
||||
// |
||||
// Author: Ryan Hipple |
||||
// Date: 10/04/17 |
||||
// ---------------------------------------------------------------------------- |
||||
|
||||
/****************************************************************************** |
||||
* Note from me: |
||||
* If you have not watched this presentation, drop everything and watch it now |
||||
* https://youtu.be/raQ3iHhE_Kk |
||||
* |
||||
* YOU MUST MASTER THIS CONTENT! |
||||
*****************************************************************************/ |
||||
|
||||
using UnityEngine; |
||||
|
||||
namespace Architecture.Variables |
||||
{ |
||||
[CreateAssetMenu(fileName = "New Integer Variable", menuName = "Architecture/Integer Variable")] |
||||
public class IntVariable : ScriptableObject |
||||
{ |
||||
#if UNITY_EDITOR |
||||
[Multiline] |
||||
public string DeveloperDescription = ""; |
||||
#endif |
||||
|
||||
public int Value; |
||||
|
||||
public void SetValue(int value) |
||||
{ |
||||
Value = value; |
||||
} |
||||
|
||||
public void SetValue(IntVariable value) |
||||
{ |
||||
Value = value.Value; |
||||
} |
||||
|
||||
public void ApplyChange(int amount) |
||||
{ |
||||
Value += amount; |
||||
} |
||||
|
||||
public void ApplyChange(IntVariable amount) |
||||
{ |
||||
Value += amount.Value; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2 |
||||
guid: f48b43e898ec8f54ca1d8845b39b9c6c |
||||
MonoImporter: |
||||
externalObjects: {} |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,33 @@
|
||||
// ---------------------------------------------------------------------------- |
||||
// Unite 2017 - Game Architecture with Scriptable Objects |
||||
// |
||||
// Author: Ryan Hipple |
||||
// Date: 10/04/17 |
||||
// ---------------------------------------------------------------------------- |
||||
|
||||
/****************************************************************************** |
||||
* Note from me: |
||||
* If you have not watched this presentation, drop everything and watch it now |
||||
* https://youtu.be/raQ3iHhE_Kk |
||||
* |
||||
* YOU MUST MASTER THIS CONTENT! |
||||
*****************************************************************************/ |
||||
|
||||
using UnityEngine; |
||||
|
||||
namespace Architecture.Variables |
||||
{ |
||||
[CreateAssetMenu(fileName = "New String Variable", menuName = "Architecture/String Variable")] |
||||
public class StringVariable : ScriptableObject |
||||
{ |
||||
[SerializeField] |
||||
private string value = ""; |
||||
|
||||
public string Value |
||||
{ |
||||
get { return value; } |
||||
set { this.value = value; } |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2 |
||||
guid: d2cbaae3519f6834c87bb047c94b8cbf |
||||
MonoImporter: |
||||
externalObjects: {} |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
Loading…
Reference in new issue