Skip to content

Commit

Permalink
- Unity PackageManager support; package.json, *.asmdef for Package an…
Browse files Browse the repository at this point in the history
…d its Editor folder

- SoVariableReference handles null variable value
- .editorconfig with Unix style newlines (due to format of where Shawn is currently working)
  • Loading branch information
Feddas committed Jan 6, 2019
1 parent 5cc6b69 commit 90b5d1b
Show file tree
Hide file tree
Showing 33 changed files with 154 additions and 38 deletions.
11 changes: 11 additions & 0 deletions Assets/SoArchitecture/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# The purpose of .editorconfig files are explained on https://docs.microsoft.com/en-us/visualstudio/ide/create-portable-custom-editor-options

# top-most EditorConfig file
root = false

# Phab forced formatting is UTF-8/ASCII Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8
File renamed without changes.
12 changes: 12 additions & 0 deletions Assets/SoArchitecture/Editor/EditorSoArchitecture.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "EditorSoArchitecture",
"references": [
"SoArchitecture"
],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false
}
7 changes: 7 additions & 0 deletions Assets/SoArchitecture/Editor/EditorSoArchitecture.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Unite 2017 - Game Architecture with Scriptable Objects
//
// Author: Ryan Hipple
Expand All @@ -12,7 +12,7 @@
namespace SoArchitecture
{
[CustomEditor(typeof(GameEvent))]
public class EventEditor : Editor
public class EditorSoEvent : Editor
{
public override void OnInspectorGUI()
{
Expand All @@ -27,21 +27,21 @@ public override void OnInspectorGUI()
}

[CustomEditor(typeof(GameEventBool))]
public class EventBoolEditor : EventPayloadEditor<bool, GameEventBool>
public class EditorSoEventBool : EditorSoEventPayload<bool, GameEventBool>
{
}

[CustomEditor(typeof(GameEventFloat))]
public class EventFloatEditor : EventPayloadEditor<float, GameEventFloat>
public class EditorSoEventFloat : EditorSoEventPayload<float, GameEventFloat>
{
}

[CustomEditor(typeof(GameEventInt))]
public class EventIntEditor : EventPayloadEditor<int, GameEventInt>
public class EditorSoEventInt : EditorSoEventPayload<int, GameEventInt>
{
}

public class EventPayloadEditor<TPayload, TGameEvent> : Editor
public class EditorSoEventPayload<TPayload, TGameEvent> : Editor
where TGameEvent : class, IGameEvent<TPayload>
{
public override void OnInspectorGUI()
Expand All @@ -57,4 +57,4 @@ public override void OnInspectorGUI()
GUILayout.Label("LastPayload: " + e.LastPayload.ToString());
}
}
}
}
8 changes: 8 additions & 0 deletions Assets/SoArchitecture/Editor/Variables.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using UnityEditor;
using UnityEditor;
using UnityEngine;

/// <summary>
Expand All @@ -11,7 +11,7 @@ namespace SoArchitecture
[CustomPropertyDrawer(typeof(FloatReference))]
[CustomPropertyDrawer(typeof(IntReference))]
[CustomPropertyDrawer(typeof(StringReference))]
public class SoReferenceDrawer : PropertyDrawer
public class DrawerSoReference : PropertyDrawer
{
/// <summary>
/// Options to display in the popup to select constant or variable.
Expand Down Expand Up @@ -118,4 +118,4 @@ SerializedProperty watchValue(SerializedProperty property)
return asSerializedObject.FindProperty("Value");
}
}
}
}
4 changes: 2 additions & 2 deletions Assets/SoArchitecture/Events/GameEvent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Unite 2017 - Game Architecture with Scriptable Objects
//
// Author: Ryan Hipple
Expand Down Expand Up @@ -38,4 +38,4 @@ public void UnregisterListener(GameEventListener listener)
eventListeners.Remove(listener);
}
}
}
}
2 changes: 1 addition & 1 deletion Assets/SoArchitecture/Events/GameEventBool.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

Expand Down
2 changes: 1 addition & 1 deletion Assets/SoArchitecture/Events/GameEventFloat.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

Expand Down
2 changes: 1 addition & 1 deletion Assets/SoArchitecture/Events/GameEventInt.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

Expand Down
4 changes: 2 additions & 2 deletions Assets/SoArchitecture/Events/GameEventListener.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Unite 2017 - Game Architecture with Scriptable Objects
//
// Author: Ryan Hipple
Expand Down Expand Up @@ -34,4 +34,4 @@ public void OnEventRaised()
Response.Invoke();
}
}
}
}
2 changes: 1 addition & 1 deletion Assets/SoArchitecture/Events/GameEventListenerBool.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
Expand Down
2 changes: 1 addition & 1 deletion Assets/SoArchitecture/Events/GameEventListenerFloat.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
Expand Down
2 changes: 1 addition & 1 deletion Assets/SoArchitecture/Events/GameEventListenerInt.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
Expand Down
2 changes: 1 addition & 1 deletion Assets/SoArchitecture/Events/GameEventPayload.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

Expand Down
4 changes: 2 additions & 2 deletions Assets/SoArchitecture/Events/UnityEventRaiser.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Unite 2017 - Game Architecture with Scriptable Objects
//
// Author: Ryan Hipple
Expand All @@ -19,4 +19,4 @@ public void OnEnable()
OnEnableEvent.Invoke();
}
}
}
}
31 changes: 31 additions & 0 deletions Assets/SoArchitecture/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Goal

ScriptableObjects used for variables and events

# Inspiration

Ryan Hippies' Unite Austin 2017 talk
* [The video for the talk is posted on Unity's YouTube page.](https://www.youtube.com/watch?v=raQ3iHhE_Kk)
* [Here is a blog post he did about the talk](http://www.roboryantron.com/2017/10/unite-2017-game-architecture-with.html)
* [The slides are on slideshare.](https://www.slideshare.net/RyanHipple/game-architecture-with-scriptable-objects)

# Setup

### Installation

These steps require Unity 2018.1.x or greater.

1. Download a release SoArchitecture0.0.x.zip from https://github.com/Feddas/SoArchitecture/releases

2. Unzip SoArchitecture0.0.x.zip into your projects Packages folder while Unity is closed. If Unity is open during the file transfer, Unity needs to be restarted to recognize the package.

```
ProjectFolder <- This should match the name of your Unity project
+ Assets folder
+ Packages folder <- Unzip into this folder
+ SoArchitecture0.0.x <- This folder should be created from unzipping
```

3. Start Unity

[Official package manager info](https://blogs.unity3d.com/2018/05/09/unity-packages-life-cycle/).
7 changes: 7 additions & 0 deletions Assets/SoArchitecture/Readme.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Assets/SoArchitecture/SoArchitecture.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "SoArchitecture"
}
7 changes: 7 additions & 0 deletions Assets/SoArchitecture/SoArchitecture.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Assets/SoArchitecture/Variables/BoolVariable.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using UnityEngine;

/// <summary>
Expand All @@ -15,4 +15,4 @@ public void Toggle()
Value = Value == false;
}
}
}
}
4 changes: 2 additions & 2 deletions Assets/SoArchitecture/Variables/FloatVariable.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Unite 2017 - Game Architecture with Scriptable Objects
//
// Author: Ryan Hipple
Expand All @@ -24,4 +24,4 @@ public void ApplyChange(FloatVariable amount)
Value += amount.Value;
}
}
}
}
4 changes: 2 additions & 2 deletions Assets/SoArchitecture/Variables/IntVariable.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using UnityEngine;

/// <summary>
Expand All @@ -20,4 +20,4 @@ public void ApplyChange(IntVariable amount)
Value += amount.Value;
}
}
}
}
4 changes: 2 additions & 2 deletions Assets/SoArchitecture/Variables/SoVariableBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

Expand Down Expand Up @@ -58,4 +58,4 @@ public void SetValue(SoVariableBase<T> value)
Value = value.Value;
}
}
}
}
13 changes: 10 additions & 3 deletions Assets/SoArchitecture/Variables/SoVariableReference.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;

/// <summary>
/// Scriptable Objects fork https://github.com/Feddas/Unite2017SoArchitecture
Expand Down Expand Up @@ -54,7 +54,9 @@ public T StartingValue
{
get
{
return UseConstant ? startingConstant : Variable.StartingValue;
return UseConstant || Variable == null
? startingConstant
: Variable.StartingValue;
}
}

Expand Down Expand Up @@ -92,9 +94,14 @@ public T Value
}
else
{
if (Variable == null)
{
throw new Exception("SoVariable has not been set. If you don't want to use one, click the dropdown and set 'Use Constant'");
}

Variable.Value = value;
}
}
}
}
}
}
2 changes: 1 addition & 1 deletion Assets/SoArchitecture/Variables/StringVariable.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Unite 2017 - Game Architecture with Scriptable Objects
//
// Author: Ryan Hipple
Expand Down
13 changes: 13 additions & 0 deletions Assets/SoArchitecture/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"packageId": "",
"version": "0.0.1",
"resolvedPath": "",
"name": "com.feddas.soarchitecture",
"displayName": "ScriptableObject Architecture",
"category": "",
"description": "ScriptableObjects used for variables and events",
"unity": "2018.2.0f2",
"keywords": [
"architecture"
]
}
7 changes: 7 additions & 0 deletions Assets/SoArchitecture/package.json.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ This is the source for the sample project I presented at Unite 2017. It features
* [The video for the talk is posted on Unity's YouTube page.](https://www.youtube.com/watch?v=raQ3iHhE_Kk)
* [Here is a blog post I did about the talk](http://www.roboryantron.com/2017/10/unite-2017-game-architecture-with.html)
* [The slides are on slideshare.](https://www.slideshare.net/RyanHipple/game-architecture-with-scriptable-objects)

# Package Manager

Releases of SoArchitecture are meant to be used with the Unity3D Package Manager. Instructions for using SoArchitecture as a Unity Package: [SoArchitecture/Readme.md](/Assets/SoArchitecture/Readme.md)

0 comments on commit 90b5d1b

Please sign in to comment.