ScriptableObjects used for variables and events
These steps require Unity 2018.1.x or greater.
A github reference allows a project to always use the latest version of this package. To reference the package, modify your projects \Packages\manifest.json file by changing
{
"dependencies": {
"com.unity.collab-proxy": "1.2.16",
to add a dependency on the SoArchitecture github repository
{
"dependencies": {
"com.feddas.soarchitecture": "https://github.com/Feddas/SoArchitecture.git",
"com.unity.collab-proxy": "1.2.16",
If you run into authentication issues, try some of the steps on this forum thread.
-
Download a release SoArchitecture0.0.x.zip from https://github.com/Feddas/SoArchitecture/releases
-
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
- Start Unity
Official package manager info.
To learn the basics watch https://www.youtube.com/watch?v=raQ3iHhE_Kk
Payload events are events that carry a value when the event is raised. Any type can be supported by inheriting GameEventPayload<,,>. Types already included are bool, int, and float.
Here's an example binding a float event to a slider
- Create a GameEventFloat - This event will be raised with a payload of the sliders current value whenever the slider is modified.
- Right click in project window
- Create => SoArchitecture => GameEventFloat
- Name the new event "MySliderEvent"
- Create a new scene
- Add a slider by right clicking in hierarchy UI => Slider
- Inside OnValueChanged, click the '+' button and add 'MySliderEvent' as the source object.
- Change the OnValueChanged function to GameEventFloat => Raise() Be sure to select the dynamic raise at the top so the event will be fed the value selected on the slider.
- Add a text overlay to the slider by right clicking the slider in the hierarchy and selecting UI => Text. This will be a Text UI object as a child of the slider.
- Add a TextStringFormat component to the text.
- Drag this text object into the "Output Text" field.
- Drag "MySliderEvent" into the
Variables To Format
field. - Change the "Format" field to "You picked {0}".
- Add a "GameEventListenerFloat" component to the text.
- Drag "MySliderEvent" into the
Event
field. - Inside Response, click the '+' button and add this text object
- Change the Response function to TextStringFormat => UpdateText()
- Drag "MySliderEvent" into the
- Add a TextStringFormat component to the text.
- Press the play button. As you move the slider the float event will be raised. As the event is raised, the text will be updated with the sliders current value.
Ryan Hippies' Unite Austin 2017 talk