Browse Source

Added the Architecture asset into the project. This asset is based on the Unite 2017 session.

master
Ken Schaefer 5 years ago
parent
commit
f5d6ff1fc9
  1. 8
      Assets/Architecture.meta
  2. 8
      Assets/Architecture/Enums.meta
  3. 15
      Assets/Architecture/Enums/EnumValue.cs
  4. 11
      Assets/Architecture/Enums/EnumValue.cs.meta
  5. 8
      Assets/Architecture/Events.meta
  6. 8
      Assets/Architecture/Events/Editor.meta
  7. 20
      Assets/Architecture/Events/Editor/EventEditor.cs
  8. 12
      Assets/Architecture/Events/Editor/EventEditor.cs.meta
  9. 48
      Assets/Architecture/Events/GameEvent.cs
  10. 11
      Assets/Architecture/Events/GameEvent.cs.meta
  11. 45
      Assets/Architecture/Events/GameEventListener.cs
  12. 11
      Assets/Architecture/Events/GameEventListener.cs.meta
  13. 8
      Assets/Architecture/Variables.meta
  14. 38
      Assets/Architecture/Variables/BoolVariable.cs
  15. 11
      Assets/Architecture/Variables/BoolVariable.cs.meta
  16. 8
      Assets/Architecture/Variables/Editor.meta
  17. 77
      Assets/Architecture/Variables/Editor/FloatReferenceDrawer.cs
  18. 11
      Assets/Architecture/Variables/Editor/FloatReferenceDrawer.cs.meta
  19. 47
      Assets/Architecture/Variables/FloatReference.cs
  20. 11
      Assets/Architecture/Variables/FloatReference.cs.meta
  21. 50
      Assets/Architecture/Variables/FloatVariable.cs
  22. 11
      Assets/Architecture/Variables/FloatVariable.cs.meta
  23. 50
      Assets/Architecture/Variables/IntVariable.cs
  24. 11
      Assets/Architecture/Variables/IntVariable.cs.meta
  25. 33
      Assets/Architecture/Variables/StringVariable.cs
  26. 11
      Assets/Architecture/Variables/StringVariable.cs.meta
  27. 7
      Assets/FirstPersonController/Scripts/MouseLook.cs
  28. 6
      Assets/FirstPersonController/Scripts/PlayerMovement.cs
  29. 8
      Assets/Scripts.meta

8
Assets/Architecture.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3c99d607772ce4347be90c8a91b9ebbb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Architecture/Enums.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4535e4d344da0844dac2544e46e61ccc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

15
Assets/Architecture/Enums/EnumValue.cs

@ -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;
}
}

11
Assets/Architecture/Enums/EnumValue.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 97a3dd7294f44774184523763afc89ca
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Architecture/Events.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7e005abc2b02b7f4eaf6a213a6077126
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Architecture/Events/Editor.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 93c4e8e5652153c468c80377a80cb93d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

20
Assets/Architecture/Events/Editor/EventEditor.cs

@ -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();
}
}
}

12
Assets/Architecture/Events/Editor/EventEditor.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8564e34357d4a224a838d71bdb631b0c
timeCreated: 1506793093
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

48
Assets/Architecture/Events/GameEvent.cs

@ -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);
}
}
}

11
Assets/Architecture/Events/GameEvent.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1f3bbdb45cfb90548ae20b51284bb3ed
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

45
Assets/Architecture/Events/GameEventListener.cs

@ -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();
}
}
}

11
Assets/Architecture/Events/GameEventListener.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6db0e2471827ae743b18e930d1a025dc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Architecture/Variables.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d24ebc2f864c32f47abd7739a250bedd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

38
Assets/Architecture/Variables/BoolVariable.cs

@ -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; }
}
}
}

11
Assets/Architecture/Variables/BoolVariable.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4d056a20c5b6bba48b50aa8bcc2993d7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Architecture/Variables/Editor.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f768077bb3d9eed4aa5a935b516fa366
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

77
Assets/Architecture/Variables/Editor/FloatReferenceDrawer.cs

@ -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();
}
}
}

11
Assets/Architecture/Variables/Editor/FloatReferenceDrawer.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d1339393180531047aef724fdc6f0f74
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

47
Assets/Architecture/Variables/FloatReference.cs

@ -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;
}
}
}

11
Assets/Architecture/Variables/FloatReference.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c02f17a3496c0f747b66a060639cc478
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

50
Assets/Architecture/Variables/FloatVariable.cs

@ -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;
}
}
}

11
Assets/Architecture/Variables/FloatVariable.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7cb18c6bb3c4bcd40b8451100e11b136
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

50
Assets/Architecture/Variables/IntVariable.cs

@ -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;
}
}
}

11
Assets/Architecture/Variables/IntVariable.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f48b43e898ec8f54ca1d8845b39b9c6c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

33
Assets/Architecture/Variables/StringVariable.cs

@ -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; }
}
}
}

11
Assets/Architecture/Variables/StringVariable.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d2cbaae3519f6834c87bb047c94b8cbf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

7
Assets/FirstPersonController/Scripts/MouseLook.cs

@ -1,4 +1,9 @@
using System.Collections; /******************************************************************************
* Initial code based on Brackey's FPS video
* https://youtu.be/_QajrabyTJc
*****************************************************************************/
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;

6
Assets/FirstPersonController/Scripts/PlayerMovement.cs

@ -1,4 +1,8 @@
using System.Collections; /******************************************************************************
* Initial code based on Brackey's FPS video
* https://youtu.be/_QajrabyTJc
*****************************************************************************/
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;

8
Assets/Scripts.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 84af533f7b759c44287ba593ee3f85c4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Loading…
Cancel
Save