Unite Austin 2017 - Game Architecture with Scriptable Objects

preview_player
Показать описание

Ryan Hipple (Principal Engineer, Schell Games)

0:00 Intro
2:38 Engineering Pillers
7:04 ScriptableObjects Basics
15:26 Modular Data
27:50 Event Architecture
38:30 Runtime Sets
45:32 No More Enums
50:33 Asset Base Systems
Рекомендации по теме
Комментарии
Автор

This was 5 years ago and yet, I still come back to this video for reference. This changed the way I use ScriptableObjects forever.

Brandon_Gui
Автор

Very good talk, we need more talks in this quality for Architecture (y)

shockergnommable
Автор

36:25 "If you write a simple inspector"

This is kinda just thrown out there. For people wondering where this button came from, paste this code in a new C# Script

using UnityEngine;
using UnityEditor;


public class WhateverYourScriptNameIs : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();

GameEvent myGameEvent = (GameEvent)target;

if
{
myGameEvent.Raise();
}
}
}

edgunther
Автор

You know, I wasn't entirely sold on scriptable objects until this talk. Thanks, it has been rather eye opening.

sirflimflam
Автор

I'm sitting here stunned, realizing how many stupid simple problems this would have solved for me if I had watched this back in nov 2017 as first posted... I've used scriptable objects for more typical data, but using them as globally available "meet in the middle" kind of user editable data is so obvious now!

dantescanline
Автор

2:38 Engineering Pillers
7:04 ScriptableObjects Basics
15:26 Modular Data
27:50 Event Architecture
38:30 Runtime Sets
45:32 No More Enums
50:33 Asset Base Systems

swapnilrane
Автор

Without a doubt the most mind blowing Unity talk ever. Excellent speaker.

zapposh
Автор

So I took this concept and ran with it a bit. Here are some things I learned and some advice for other developers:

All my ScriptableObjects inherit from a base class ScriptableGameObject, that has a few fields on it, most notably a string for a developer description. This is never actually used but it basically means any developer on the project can write anything they want about any object in the inspector.

Also, It's probably best to also make a ConstFloatReference, which is the same as a FloatReference (or whatever) but doesn't let you change the value in your code (you can still set a custom value in the inspector and can still reference a normal variable). This has no bearing on the actual game and there's no such thing as a "constant" in your actual variable classes, but it means that at the reference point, you can't accidentally change the value of a variable in your code. This is useful if, for example, you have UI elements that read the players health but you want to make sure that they cannot change the players health under any circumstances, so it's effectively a "one-way" variable link. It's just an extra level of safety at the cost of a little bit of extra work.

I also have a generic ScriptableObject-based ObjectPool which takes a prefab and can automatically handle creation/enabling/disabling etc of objects in the pool. This is extremely useful because it encourages me to use more object pools (I can create them basically as I need them with a simple right click, and create, say, a "Pistol Bullet Pool") which itself results in a more efficient game because every weapon that fires projectiles can very easily use an object pool and even share them (in the case of multiplayer).

Lastly, if you combine this with pluggable stuff like Pluggable AI as seen in the other Unity videos on this topic, you can get a lot of flexibility. In general you should be favoring references over a complex inheritence heirarchy or a lot of singletons. But singletons are still required, unfortunately. For example, it's pretty much impossible to set a game state without using a singleton. I mean you can technically use a game state variable, but if you want all of your game objects to, say, not move when the game state is "Paused", you either have to use a singleton to store the gamestate so you can check it, or you have to reference a game state variable in each object, which can be an absolute pain because you will likely have to do it with every prefab in your entire project.

pt
Автор

This is an amazing demonstration of the power of ScriptableObjects. I spent a week re-watching this video, and modifying the demo scenes, until I attained complete understanding. It illustrates I've been overlooking the power of using ScriptableObjects, as opposed to singletons, in my work. I especially like your descriptions of what the 'wrong singleton alternatives' are - you perfectly pointed the path down which I went, not knowing what Unity was capable of.

Thank you for sharing this excellent work. I can tell you hid company secrets, as you hinted at in the demonstration - yet you pointed out all the salient points of ScriptableObjects quite well anyway. Replacing the GameEvent listener list with Delegates is an exercise to be done by the student, for extra credit. ;-)

Klachemin
Автор

@32:41 lmao he actually moved the background art thing up to perfectly not-cover the word "hookers." Obviously great presentation overall but I specifically appreciate the effort that went into this easter egg of a meme

the-one-and-only-squeeze
Автор

This really is a great talk, as you pointed out, we have lots of info on how to accomplish very specific things in Unity, but I feel that design best practices / design patterns specifically within Unity is one of the areas I have the hardest time getting information about.

AwfulPun
Автор

24:00 float reference abstraction - my god the sudden realisation that this is exactly what I was looking for. it's so elegant. THANK YOU

Woodythehobo
Автор

"If (scene.menuname != menuscene)" is how I solved a problem in my game very recently. I had been pretty proud of myself for that. :(

someoneontheinternet
Автор

Does this guy have a book or a video series that he is selling somewhere ? Those architecture tips are golden, I would GLADLY pay for more.

hthought
Автор

Wish we had an example of that inventory system, saving/loading and resetting those scriptable objects must be quite tricky. Not sure if I want to attempt that myself yet.

OtakuDYT
Автор

This is pure gold, ten years working in Unity and I finally know this

CristhianDiaz-thsq
Автор

this talk alone its worth going to unite

eduardo-cat
Автор

I'm so glad someone directed me to this talk. Had no idea how powerful Scriptable Objects could be, and will definitely be watching the Richard Fine and The Hack Spectrum talks next. Thanks Ryan!

beardlessdev
Автор

I cant express how important the video is ... THis is one of the best video in UNITE, THE demonstrator is super knowledgeable and has shown powers of SOs, and is really good at demonstration. THank you very much

entertainmentoverloaded
Автор

That was an amazing talk! We definitely need more architecture guidelines for Unity.

sergioabreu-g
visit shbcf.ru