Unite Austin 2017 - Game Architecture with Scriptable Objects

Поділитися
Вставка
  • Опубліковано 25 чер 2024
  • Scriptable Objects are an immensely powerful yet often underutilized feature of Unity. Learn how to get the most out of this versatile data structure and build more extensible systems and data patterns. In this talk, Schell Games shares specific examples of how they have used the Scriptable Object for everything from a hierarchical state machine, to an event system, to a method of cross scene communication. Sample project: github.com/roboryantron/Unite...
    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
  • Ігри

КОМЕНТАРІ • 377

  • @Brandon_Gui123
    @Brandon_Gui123 Рік тому +100

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

  • @edgunther8136
    @edgunther8136 4 роки тому +137

    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;
    [CustomEditor(typeof(GameEvent))]
    public class WhateverYourScriptNameIs : Editor
    {
    public override void OnInspectorGUI()
    {
    DrawDefaultInspector();
    GameEvent myGameEvent = (GameEvent)target;
    if (GUILayout.Button("Raise()"))
    {
    myGameEvent.Raise();
    }
    }
    }

  • @shockergnommable
    @shockergnommable 5 років тому +371

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

    • @travistrue2008
      @travistrue2008 5 років тому +7

      I agree. I tried implementing a more designer-centric development process in our process at a previous company I worked at years ago, but I never had the time to develop it to the point of discovering the capabilities of ScriptableObjects. UnityEvent was a Godsend, and a worthy successor to SendMessage, which had potential, but some serious caveats and performance issues.

    • @Laumania
      @Laumania 4 роки тому +20

      Totally agree. Far to many videos are purely about how to make X work. That's fine, but when you approach game dev a little more professionally, these architecture decisions/challenges comes up pretty fast - and are very hard to find the "best practice" for often.
      Personally I come from a coding background, so I'm not a super fan of all this drag'n'drop stuff. Sure of cause the editor is awesome to build 3d worlds etc, but like references between things very quickly becomes a nightmare. Yes you can do "Find references in scene"....but what if you have multiple scenes?
      Generally figuring out how things are referencing each other is one of my big challenges - as I want things to be a simple as possible. Too often, if not always, it's based on "something you need to know" - and that sucks :)
      Haven't watched this video to the end yet, hoping for some ideas - however I am already running a lot of stuff "event" driven, via a Message system in code, so I'm on the same path.

  • @dantescanline
    @dantescanline 5 років тому +53

    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!

  • @sirflimflam
    @sirflimflam 6 років тому +144

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

    • @rodrigolegendre8950
      @rodrigolegendre8950 6 років тому +9

      Same here... Holy shinning cubes! Scriptable objects just went from "meh" to "amazing!" in my mind. I was so not understanding their advantages! I'm shocked at how deep I was down in Dunning-Kruger effect...

    • @AnkitSharma83
      @AnkitSharma83 5 років тому

      actually, we have something similar in tv production animations with assets constantly referenced in various animation shots. and any change in the assets gets an update throughout. Talk about updating all the 200 shots just for more skin texture switch.

    • @ParkingLotStudioGames
      @ParkingLotStudioGames 3 роки тому +1

      That's exactly what I went through, that's probably why he was shitting on Richard, cause his talk was meh at best but this is brilliant

  • @pt8306
    @pt8306 4 роки тому +99

    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.

    • @ludidong6609
      @ludidong6609 3 роки тому +2

      Hey Paul, thanks! This is super helpful!

    • @litgamesdev
      @litgamesdev 3 роки тому

      I was wondering about your second point. It would seem without that everything would be just be made into a global which is really dumb. For your reference variable, is it just a wrapper essentially for the real variable and just returning the value? That seems like it would be the smartest thing you can do to make sure that not everything can write to everything.

    • @pt8306
      @pt8306 3 роки тому

      @@litgamesdev The reference wraps the variable, but also contains a value of type T which can be used instead, selectable from the inspector (it also contains a bool to say if it's using the reference or not). This allows developers to easily have "one-off" cases.
      Nothing here is global.

    • @pixelpat5276
      @pixelpat5276 3 роки тому

      Thanks for your help :). Your last point about needing to use a singleton, what if you are just activating everything that the camera sees and loading in chunks then it might not be that much effort to pause all the objects in sceen using a scriptable object event.?

    • @pt8306
      @pt8306 3 роки тому +2

      @@pixelpat5276 my general rule is: if it can be done without a Singleton, it probably should be. If you have a system to work with your camera that makes it self sufficient with minimal dependencies, then you're golden. The reason singletons are bad in the first place is because they add hidden dependencies to your objects and if that can be avoided, then it's probably a good thing.

  • @swapnilrane24
    @swapnilrane24 3 роки тому +115

    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

  • @zapposh
    @zapposh 4 роки тому +48

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

  • @Klachemin
    @Klachemin 5 років тому +63

    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. ;-)

  • @AwfulPun
    @AwfulPun 5 років тому +22

    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.

  • @skweebus
    @skweebus 5 років тому +58

    @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

  • @Woodythehobo
    @Woodythehobo 5 років тому +5

    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

    • @herohiralal3255
      @herohiralal3255 4 роки тому

      Can you please tell me the use for this, like what's the entire point of using floatvariable scriptable object & floatreference class?

    • @prestonboumann2571
      @prestonboumann2571 4 роки тому

      @@herohiralal3255 i think this is what he said: You don't reference the "owner" at all to get the value because the SO holds the value. It's better and safer for designer because it gives them a GUI to create their own values with other SO features to help. Changes affect all scenes and any objects which rely on them(stops accidental prefab changes and is a form of serialization).
      That's what I got.

  • @beardlessdev7628
    @beardlessdev7628 6 років тому

    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!

  • @Skarredghost
    @Skarredghost 4 роки тому

    I have just discovered this video and I have to say that it is amazing! For the first time, someone has explained me very well how ScriptableObjects can be used

  • @CodingWithUnity
    @CodingWithUnity 6 років тому

    So gratifying when i see a system that resembles so closely a system i was already doing. Great talk!

  • @MatthewChowns
    @MatthewChowns 6 років тому +2

    Thank you for the re-upload! This is a great talk and the audio de-sync would've been a pain when I refer back to this while coding later.

  • @jeffreycordova9082
    @jeffreycordova9082 5 років тому

    This was an incredibly useful speech that hit many issues that I struggled with. Virtually every point I have worked at some point but was unsatisfied with my solutions. After watching this it's time to take another whack at it. Thanks!

  • @fidel_soto
    @fidel_soto 6 років тому +1

    This is one of the best unity talks ever. Thank you very much.

  • @entertainmentoverloaded5700
    @entertainmentoverloaded5700 2 роки тому

    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

  • @nv7287
    @nv7287 5 років тому +3

    Just awesome :) thanks a lot! Great pace, info and humour couldn't think of a nicer way to learn :)

  • @HunterLawson_GameDev
    @HunterLawson_GameDev 6 років тому +2

    I'm a big fan of scriptable objects already. But I definitely had not thought about some of these use cases. Thank you so much! Great talk! :D

  • @mitchiarikov2614
    @mitchiarikov2614 3 роки тому

    This video is a classic! Thank you. I am watching it for the 3rd time and get something new out of it every time.

  • @elbow005
    @elbow005 6 років тому +1

    You rock man! An inspiring talk and presentation, think I can't go back to repeating ill practices after learning from this session.

  • @tweetymr
    @tweetymr 3 роки тому

    This is the best demonstration on how to use ScriptableObjects by far! Learned so much from it. Thanks fot that talk :-)

  • @CristhianDiaz-th8sq
    @CristhianDiaz-th8sq 8 місяців тому

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

  • @JerryIsdale
    @JerryIsdale 6 років тому +1

    VERY professional and well done talk. Thanks for the slides, blog and github code!

  • @devilmonkey471
    @devilmonkey471 6 років тому

    What an excellent, relatable and casual speaker this guy is. Great job, great subject! Thank you Ryan.

    • @Klachemin
      @Klachemin 5 років тому

      I agree, he was very easy to listen to, not condescending in the least, intelligent, articulate. I would like to see more game development topics presented by him.

  • @sergioabreu-g
    @sergioabreu-g 2 роки тому +2

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

  • @mattjclay
    @mattjclay 3 роки тому

    I started using these for pretty much everything. They solve pretty much every issue I typically have to deal with. I never wanted to use multiple scenes because it was a pain to serialize and deserialize data between scenes. Now it doesn’t matter. I can just drop in whatever I want without a care in the world.

  • @katiecates1695
    @katiecates1695 2 роки тому +3

    So very helpful and eye opening! Thank you, Ryan and Unity!

  • @imaginationrabbit
    @imaginationrabbit 6 років тому +2

    This is a brilliant approach- thank you for the talk and for the upload ^_^

  • @someoneontheinternet3090
    @someoneontheinternet3090 4 роки тому +5

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

  • @Dominik-K
    @Dominik-K Рік тому

    This is an amazing talk and it clearly outlines many patterns to make it easier for developers to crate games on solid games architecture

  • @HandcartRule46
    @HandcartRule46 4 роки тому +1

    7 minutes in and love the talk already - great communication skills

  • @leakyabstraction
    @leakyabstraction 5 років тому +1

    Thanks for this great talk, especially for the demos and use cases presented; still very useful in 2018. :) And exactly what I was looking for, because as a Unity noob (but someone who understands SOLID programming in .Net) I had a lot of dilemmas about how to implement loosely coupled design in Unity, and most sources don't answer this at all. I also appreciate the critical tone towards some Unity characteristics, e.g. the curly brace placement and relying on magic strings.

  • @harrysanders818
    @harrysanders818 5 років тому +4

    This is so fantastic, it leaves me speechless. A breathtaking talk. Thank you!

  • @hthought
    @hthought 5 років тому +32

    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.

  • @TalisBarbalho
    @TalisBarbalho 6 років тому +6

    This talk is amazing.

  • @KSF095
    @KSF095 Рік тому

    I'm still loving it
    Use it in every project :)
    Thank you so much haha

  • @kpickett9128
    @kpickett9128 Рік тому

    this talk is amazing and has totally changed how i will approach setting up unity projects in the future!!

    • @sohodollie7643
      @sohodollie7643 Рік тому

      True, the FloatVariable scriptableobject thing blew my mind lol

  • @eduardo-cat
    @eduardo-cat 6 років тому +23

    this talk alone its worth going to unite

  • @neofox2000
    @neofox2000 6 років тому

    This talk has helped me tremendously!
    Thank you so much :)

  • @goehlergamedev
    @goehlergamedev 2 роки тому

    Holy mother, this is what I've been looking for! Great talk!

  • @TheEarlyAstrotype1024
    @TheEarlyAstrotype1024 11 місяців тому

    On reading unity forums and subreddit, I always find myself keep getting back to this video, kinda interesting

  • @vishalgupta5288
    @vishalgupta5288 3 роки тому

    This is one of the most amazing talks I have seen.... Demonstrating stuff as you say about it... Yayyy to Scriptable objects.... Btw that we are not monsters line was XD

  • @DoomCatcher
    @DoomCatcher 2 роки тому +2

    This is very useful, its a shame there isn't people like him (that I'm aware of) making unity courses or books that go through how to apply this stuff in detail, I'd find it very useful to have a book/course that goes through how to apply this step by step rather than an overview.

  • @adnanshaukat412
    @adnanshaukat412 5 років тому

    i didn't know until now that scriptable objects are important for game architecture. I always wondered how Developers manage to do this in AAA Games. Really eye opening talk. Recommended Talk!!!!

  • @Rob64Gaming
    @Rob64Gaming 5 років тому +2

    Good lecture
    Keeping the code clean is super important

  • @novikovPrinciple
    @novikovPrinciple 6 років тому +1

    While eye-opening, this presentation sent me down a two-day rabbit hole which consisted of me slamming headfirst into scripting mania and error headaches. Making float variables was the easy part. I can barely customize the editor to display them in the Inspector!

  • @kyleme9697
    @kyleme9697 2 роки тому

    Been doing Unity at home for a couple years now and always knew I should be using Enums. I used them for the first time last night, spent a bunch of time setting up a bunch of stuff using them ... then added a new one near the top of the list ... OMG !! ... it didn't keep the values I set where I used them !! ... well THATS good to know !! ... and here I am :)

  • @Chaser324
    @Chaser324 6 років тому

    I really like the modularity and designer-centric focus of this approach. I use Zenject now and like it, but it's often not quite as easy to pivot with zero programmer involvement.

  • @darkfafi
    @darkfafi 6 років тому +1

    An amazing talk. Thank you so much!

  • @sigtrapgames
    @sigtrapgames 5 років тому +9

    For anyone interested - we've just open-sourced our implementation of this concept, called SmartData. It's comprehensive, powerful, extensible, includes custom editors and even a live node-graph visualizer/debugger. github.com/sigtrapgames/SmartData

  • @14DimensionEnterprise
    @14DimensionEnterprise 5 років тому +1

    Sample project's link, there is missing files? Video shows there is Demo07-inventory, but at link, there is none.

  • @OtakuDYT
    @OtakuDYT 6 років тому +14

    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.

  • @paulkerrigan9857
    @paulkerrigan9857 5 років тому +4

    This is fascinating. In a lot of ways, Unity and its particular setup seems to get in the way when you try to program from a typical perspective. I'm very new to it, so I'm not fully on board with its style of doing things yet.
    You've created some very clever ways of doing things that embrace Unity's strengths and that's pretty awesome. This and Richard Fine's talk about ScriptableObject should be required viewing. Thank you very much! :-)

  • @powerpoison
    @powerpoison 4 роки тому

    this looks great and the talk is huge and very well done, It's just really hard for beginners to understand how to correctly implement them, or this is how I'm feeling

  • @peterpants7
    @peterpants7 6 років тому +1

    Great concepts here. Thanks for the talk

  • @andylockhart257
    @andylockhart257 4 роки тому

    Wow. What a fantastic presentation!

  • @rexxthunder
    @rexxthunder 6 років тому

    Just tried the event system. Works great!

  • @subliminalcastillo2126
    @subliminalcastillo2126 3 роки тому

    I'm a very new programmer. I started learning C# & Unity Development in late July of 2020 (it is late September 2020 as of writing this.)
    This talk has helped me out so much, that I cannot even describe the sheer thankfulness, and happiness I have from it.
    I'm currently at that point where I fully understand C# on a fundamental level. I'm familiar with the dynamic of value types & reference types on an intuitive level, and I am also familiar with all data types and how to properly implement them in accordance to eachother.
    The problem I do have though- what is the most efficient manner to use all of these tools together, in order to create the cleanest, most efficient, and modular manner?
    I really really like the system that he presented here, and I am going to be using it from here on out. This is a fantastic way to create systems that are decoupled from eachother. Utilizing the data types are the shared resource between different systems is a take that I have never even considered doing. I always thought that you HAD to reference system to one another, in order to create any sort of communicative functionality between said systems.

  • @USBEN.
    @USBEN. 2 роки тому

    Amazing talk. This will help me hugely. I was soo annoyed having to hard wire everything. Not anymore!

  • @Grempington
    @Grempington 6 років тому +6

    So to make sure that I've got this architecture concept straight, I'd like to use scriptableobjects for my multiplayer game.
    For this reason, I'd like the shared configuration of this type - things like Max Health etc., to be FloatVariable, IntVariable, and so on as required (Or simply - BaseConfiguration to hold all of them together, increased locality).
    In order to let our UI bind itself to the player's data, I'd like to use FloatReference, IntReference, etc (Or simply - PawnStateReference - holds everything you intend other systems to interact with, leaving other fields as true private fields for encapsulation)
    Then, the player our UI recognizes will have PawnStateReference hold the PawnStateVariable SO, and other clients of the exact same type/prefab will use the "constant" (isn't runtime a better name?) instead.
    Simple, client and other players share the exact same components with the player having an additional Input script that handles converting the inputs to actions via client pawn.
    UI only knows what our client pawn is doing extensibly, and if I'd like to add UI elements per every other player, I can use a RuntimeSet of all pawns in the scene and access the PawnStateReference from there, as it'll be public. I don't even need to add a messy "IsClient" boolean or whatever because I could just compare the PawnState reference with the one my UI recognizes.
    Is this considered an attempt to overengineer scriptableobjects into my game or does this seem like proper usage of the proposed architecture?
    Thanks.

  • @KenmoreChalfant
    @KenmoreChalfant 6 років тому

    I like the idea of using an asset as a source of publicly communicating some data. It reminds me of a Unix Socket in the unix/linux world, a sort of public channel for reading/writing data.

  • @TricoliciSerghei
    @TricoliciSerghei 8 місяців тому

    Very nice presentation, thank you very much Ryan!

  • @Mohammad-kx2rk
    @Mohammad-kx2rk 6 років тому

    Great Subject - Awesome Talk .

  • @DerDude87
    @DerDude87 6 років тому

    Great talk, Ryan!

  • @CodingWithUnity
    @CodingWithUnity 6 років тому +1

    With the runtime set list, can you not reference objects that you instantiate and destroy at runtime? I get a type mismatch when i attempt to do so. I made a serializable class to hold the list and put the class on a gameobject and it worked. but that kinda defeats the purpose

    • @RyanHipple
      @RyanHipple 6 років тому +1

      That type mismatch is just an editor display quirk, the data is still in tact. You can make a custom editor to get it to draw correctly.

  • @muzboz
    @muzboz 3 роки тому

    Very cool. Very enlightening. Thanks!

  • @travistrue2008
    @travistrue2008 5 років тому +5

    This talk, and the 2016 talk by Richard Fine are huge eye-openers, and greatly appreciated! I was wondering though: would it be a good idea to make the GameEvent and EventListener classes generic? That way, it can be parameterized for other generated UnityEvent types.

  • @dusandragovic09srb
    @dusandragovic09srb 4 роки тому

    Didn't play that part, but I saw it in game review videos. ;)
    Kain!

  • @pmoneyish6869
    @pmoneyish6869 Рік тому

    So basically variables that may need to be shared between different "systems" could/should be individual SO's so it's easy to do so. That's pretty cool!

  • @alexkostas2627
    @alexkostas2627 5 років тому +1

    Really good and helpful talk!
    43:47 when the camera man is sleeping :)

  • @ssmasrour
    @ssmasrour 2 роки тому

    I tested it and combined it with pluggable approach. this architecture really challenges other architectures.
    Authorable for non-coders and easy to maintain

  • @jjackVII
    @jjackVII Рік тому +1

    RuntimeSet {
    List items
    }
    Why, god!?
    (amazing presentation and content)

  • @ugnelism
    @ugnelism 3 роки тому +3

    This is super nice talk. I've used this architecture in a couple of
    games and found myself often re-writing the same boilerplate code (for
    events), so I've found a really nice open-source library for it:
    github(dot)com/chark/scriptable-events. I really recommend using it!

  • @dennisr.2787
    @dennisr.2787 5 років тому +6

    Hey Ryan, awesome talk, really gave some good insights! Could you tell me how you achieve the selection the way it is shown at 20:55 ?

  • @jamesk7416
    @jamesk7416 6 років тому

    Great talk, thanks!

  • @SaifaldeenSAH
    @SaifaldeenSAH 6 років тому +13

    Good Job.

    • @Chaser324
      @Chaser324 6 років тому +9

      This is a re-upload of a previous version of this video that had audio sync issues. They also could've been there in person or maybe they're even a co-worker or friend that helped edit or critique the presentation. Why would you put someone on blast just for saying, "Good Job"?

  • @ZoidbergForPresident
    @ZoidbergForPresident 6 років тому

    Cool stuff, thanks!

  • @dusandragovic09srb
    @dusandragovic09srb 4 роки тому

    Great talk!

  • @LesusGames
    @LesusGames 4 роки тому

    Outstanding. Downside, I not have a lot to recode and reconsider.

  • @Stevejustt
    @Stevejustt 4 роки тому

    This is great!

  • @godamo9956
    @godamo9956 6 років тому

    Thanks and good job .

  • @powersx2508
    @powersx2508 2 роки тому

    By the way it is great talk thanks for the efforts.

  • @scarneck180
    @scarneck180 6 років тому +1

    Thanks so much for the talk! I'm curious about your "much more generic" version of these scriptable reference variables. Is it limited to types you've defined and created property drawers for or is there a way to make it truly generic? Property drawers don't seem to work very well for generics and I wasn't able to make it work with PropertyField just hoping for a SerializedProperty named "value" (or "constantValue", etc.).
    I have a sort of Blackboard I made a while back, which behaves similar to the animator parameters, where the types can be Bool, Int, Float, Vector3, Object, Custom (anything derived from object - doesn't inspect well..) and a BlackboardValue has a boolValue, intValue, etc, and I just only draw its current type (and value, except for Custom).
    Are you able to share or at least hint at what you have in this regard?

    • @RyanHipple
      @RyanHipple 6 років тому +4

      My generic version of this has an editor where you can pick a type and it will generate code for it, so any type can be used.

    • @scarneck180
      @scarneck180 6 років тому

      Thank you for responding. I haven't even played with code generation yet... might have to give it a try!

  • @abalorias333
    @abalorias333 6 років тому

    Great talk Ryan. Guys, What do you think about the events solution presented here? I found it one of the most interesting from the design and testing perspective

  • @St4rdog
    @St4rdog 6 років тому

    Unity should be using these type of SO references for their color pallette swatches.

  • @SeanLange
    @SeanLange 6 років тому +2

    Any thoughts on how to pass a variable(s) with the GameEvent? GameEvent like Event

    • @Grynjolf
      @Grynjolf 2 роки тому

      Did you figure out a solution?

  • @masterytyrantfuture
    @masterytyrantfuture 3 роки тому

    I love the idea of SO variables, but it doesn't seem that the property drawer can handle array variables. I've tried to do it and even used includeChildren in the PropertyField method, but the foldout doesn't seem to work...

  • @masterytyrantfuture
    @masterytyrantfuture 4 роки тому

    I'm trying to recreate the PropertyDrawer you've used for the FloatReference class, but how did you create the popup menu and bind it to the UseConstant variable? Do you have any code snippets please?

  • @tylerwong3491
    @tylerwong3491 4 роки тому

    Tried implementing the videos' design pattern, but got stuck at FloatReferenceDrawer.cs where property.FindProperty("UseConstant") does not seem to work for a SerializedProperty.

  • @ReverendWolfgang
    @ReverendWolfgang 6 років тому +8

    how does the player hp setup extend to enemies? does each enemy get a SO of it's own for their current hp or do you keep it stored locally in a variable in their prefab?

    • @RyanHipple
      @RyanHipple 6 років тому +14

      The simplified form of the variables that I presented would probably not be the best choice for use on a variable amount of enemies. Alterations on the concept can be made to work for that, though. You could have the variable be instead backed by a list or dictionary so that you can say "give me the hp for enemy x". You could also use a different pattern for things like that. The VariableSets approach I mention could make it easy to track a list of objects and you could have each own own its own state.

    • @Morphexe
      @Morphexe 6 років тому +1

      Yeah, after watching this I found the concept cool and very usable, on smallish projects. This issue is something that bothered me and I can find a perfect solution for that, which is a shame, since I really like the concept.

    • @RyanHipple
      @RyanHipple 6 років тому +11

      It is never a good idea to take a concept and force it to be the solution to all problems (like I often see with singletons).
      The variable system is really good at tracking and responding to a high level state. This does not really make sense for HP on a bunch of enemies. I would place the enemies in a runtime set and have a different system scan through that to manage enemies. The dynamic variables have worked really well on large projects managing things like player state, configuration settings, quest state and other high level concepts.

    • @Morphexe
      @Morphexe 6 років тому +2

      I agree I think I explained myself wrong, I am not saying that this system is THE SYSTEM to fix everything, I was trying to convey that I haven't found a good way to implement multiple variables =).
      Also, amazing talk Ryan! Thank you for that =)

  • @Fennel341
    @Fennel341 5 місяців тому +1

    Great talk, web lacks architecture advice for Unity developers. I wonder how they handle version source control issues using this approach. There are many changes after each game start, so it should be some type of runtime folder that must be in .gitignore file. But in that case game either will not start right after clone game repository or scriptable objects should be created by themself.

  • @Monetai
    @Monetai 6 років тому +5

    Awesome talk, I really like the floatReference idea, but there is something I struggle to understand. How can I use float reference for runtime instance of object? Like the buildings health in your RTS exemple. We can put all the SO in runtime sets or dictionnary but it seem to be a "hacky" solution. And I can't figure how runtime sets and events can resolve totally the need of singleton or static reference, if I want the room where the player is standing or if I want to call a function of my saveSystem with parameters the singleton seem to be better.

    • @AkioJunichiro
      @AkioJunichiro 5 років тому

      I'm asking myself the same question for runtime instance. Have you had an answer since then?

    • @gamerholic3214
      @gamerholic3214 4 роки тому

      Correct, SO was never intended to be a one stop solution for all. Understanding and combining SO usage where appropriate along with singleton just gives you an upper hand when making decisions in architecture.
      However, If you don’t want the singleton approach and want a more robust gameManager for larger scale games, then you can look into using a Dependency Injection framework.

    • @MaharbaRacsoChannel
      @MaharbaRacsoChannel 4 роки тому +2

      You make a MonoBehaviour called Scope. Inside the Scope are dictionaries where SOs are keys. Values of the dictionaries can either be local copies of the SOs, real values (like float, bool, int, etc) for a little better performance an less memory, or a cacheable index of a list that has the real values for the best performance. Inside your other code, you call a method like Scope.GetFloat(SOFloat). Then, what GetFloat does is try to use SOFloat in a dictionary to get the value to return and, if it doesn't find it, an entry is created, initialized, and returned.
      PD
      For the cacheable index of a list. You'd cache the index inside a FloatReference instance, you'd pass that FloatReference to GetFloat instead of an SOFloat, and you only get the index from the dictionary if the SO referenced by FloatReference has changed or if it's being used with a new Scope. That way, getting the scoped value, most of the time, just means getting a value at an index from a list which can be a lot faster.

  • @Caldaron
    @Caldaron 6 років тому

    Jesus! This stuff is fucking golden!

  • @diligencehumility6971
    @diligencehumility6971 Рік тому

    I use both, a singleton-scriptable-object. You can access it from every, without drag-n-drop the asset into the inspector everywhere.

    • @RenegadeVile
      @RenegadeVile Рік тому

      You reintroduce the tight coupling problem that singletons bring though. And ScriptableObjects are accessible from everywhere anyway. They're assets, so you can reference them like any other asset from within another class as normal. Like referencing a texture or an icon.

  • @tomwhitcombe7621
    @tomwhitcombe7621 6 років тому +1

    What I'm curious about is how do you handle dynamic actors, like enemies that spawn? If they don't already exist do you have to create new scriptable objects variables/events at runtime (can you?) for each new actor and how do you pass them onto the system's that read/monitor/register them?

    • @The28studio
      @The28studio 6 років тому +1

      Tom Whitcombe yes , you can instance SO on realtime .
      Actually I do that for most part .
      Refer to the documentation.

    • @MrKyokure
      @MrKyokure 6 років тому

      I think you can hook an event to every class that needs the reference to the enemy, so whenever an enemy is instantiated an event is triggered and send that enemy to whatever class needs it.

    • @TehGM
      @TehGM 5 років тому

      Kinda late reply, but I think that mixing ways is not bad if it works better. Each type of event (SO delegate pattern, UnityEvent or straight out C# event) has it's own benefits.

  • @rohanvaradkar1110
    @rohanvaradkar1110 2 роки тому

    At 36:43, the raise button there on Ryan's screen below GameEvent, that raise button is not there on my unity screen? Can someone tell me how to enable it? I have created an almost exact demo which works exactly the same. Yet, the raise button isnt there. I am using unity 2020.3.

  • @MrRafarel
    @MrRafarel 5 років тому +1

    Thanks for this great talk, I learned a lot about ScriptableObject and Event pattern.
    Is there any good way to pass some arguments using GameEvent?
    Like the object that emits the event or any other params of my choice?
    Something like the way C# EventHandler & EventArgs?

    • @MrRafarel
      @MrRafarel 5 років тому

      Thanks for the answer, I'll give it a try!

    • @iDerp69
      @iDerp69 3 роки тому +2

      @@MrRafarel The person you responded to deleted their reply :( Do you still use this pattern?