Game architecture with ScriptableObjects | Open Projects Devlog

  Рет қаралды 247,520

Unity

Unity

Күн бұрын

Пікірлер: 229
@unity
@unity 4 жыл бұрын
If you are new to ScriptableObjects and want to understand them a bit better first, there's a link in the description to another video on the basics. Then you can rewatch this one with more context. They're a very powerful tool (and deceivingly simple to use!) so we advice getting familiar with them 👍🏻 Do you already use them in creative ways? How?
@chris.davidoff
@chris.davidoff 4 жыл бұрын
Connections the UI! Just like you showed here
@aldigangster123
@aldigangster123 4 жыл бұрын
I wanna put out a big fat warning for using the ScriptableObject architecture to get rid of dependencies! I implemented it with the identical named asset from the store and after watching Ryan Hipple's talk. What sounds like a gift from heaven first, can end in your biggest nightmare very quickly. That is: using ScriptableObjects (SO) completely removes any links. You are not able to see, which class uses or doesn't use this SO "channel". I had like 30 different SO implementations in my project, from input, to all kind of in-game events, then this nightmare became apparent. I could not follow up anymore on who or what actually listened or used those SOs, didn't know what I can safely delete ("maybe some GameObject still uses this SO?" was a common question). It became such a headache at an relatively early stage that I quickly backed off and removed this pattern completely out of my project! Instead, I'm using classical dependency injection - this way, I can see exactly in my IDE (Visual Studio) which class is using what function. And I'm using additive scene loading, to load my game scenes on top, while I have a manager scene from the beginning running at all times (eliminating need of Singleton Pattern). This Manager scene (with Input, SceneManager, Network, Saving/Loading, etc.) populates references to the newly added scene if needed. YES, this makes it harder to just drop in 2-3 components and playtest them quickly without NullRefExceptions, HOWEVER: you can always write your managing code in a way, that it allows all kind of quick playtests with different components, as long as you have your Core Manager scene loaded in the editor and everything else on top. Personally I would never go back to Scriptable Object Archticture, since I learned how to use Additive Scene Loading and inject dependencies over multiple scenes. However I can see where SO Architecture works fine on very small sized projects, like a pin ball game, or VERY simple mobile action game, etc. For anything more complex, anything like an RPG - don't use it for code / logic, only use SO for things like items, buffs, dialogue, ...
@chris.davidoff
@chris.davidoff 4 жыл бұрын
@@aldigangster123 you can always use "Find reference in scene" but I see your point. I have not had the issues you have had though personally
@gavriktonio
@gavriktonio 4 жыл бұрын
​@@aldigangster123 ​ Very good point indeed. I also started implementing my SO system after Ryan's talk, and I had to pick up a reference viewer plugin just for that reason. I did however change the idea a bit, where the events are built into the variables themselves, and scripts can subscribe only to certain variable's changes. That way it's not like everything goes through the same channel.
@Darbotron666
@Darbotron666 4 жыл бұрын
@@aldigangster123 Completely agree. I said the same myself in a much longer reply :) This approach is brilliant on paper, and great for rapid prototyping on a small-ish scale but it falls apart from combinatorial explosion at any meaningful scale - especially as the team size involved increases...
@AkiiiMatcha
@AkiiiMatcha 10 ай бұрын
This is actually just a representation of the Observer pattern with pub sub functionality. Really inspiring, I come from a Fullstack Software background and this is really what I was looking for. Perfectly encapsulating the data from the business logic and building a modular way from then to interact without forcing a hard reference. Really good content ❤
@ilcanalechenonce
@ilcanalechenonce 4 жыл бұрын
Whoever decided to make this tutorial: thank you
@FM_GOBi
@FM_GOBi 4 жыл бұрын
Thank you Unity for making a tutorial on proper code architecture. There are so many tutorials out there that teach us beginners anti-patterns, we need you guys to step in and show us how to build our games properly like this. I've watched this video with my Evernote and took notes along the way. I am going to download this open project and study it now. This is exactly what we needed. Also, I love this short devlog/tutorial video format. I can't watch very long videos, don't have time for it. This is more up my alley so maybe do both kinds of formats, long and short ones. And more on proper game architecture please. It's much needed and appreciated!!! 💖💖💖
@ciankiwi7753
@ciankiwi7753 3 жыл бұрын
THIS ^^^ alot of tutorials will show how to complete the task in a vacuum, but fail to explain how to put it into an actual game.
@pt8306
@pt8306 2 жыл бұрын
@@ciankiwi7753 In some ways you actually want to do tasks in a vacuum - that enforced modularity. But I think I get what you're trying to say. Overall though, most tutorials really are very bad, I'm glad we have some proper architecture advice.
@genericmeme
@genericmeme 4 жыл бұрын
Unrelated but I love voiceover guy's voice. Instantly recognisable and very calming.
@erickcardozo462
@erickcardozo462 4 жыл бұрын
This is where Unity beats Unreal and any other Game Engine undeniably: Education.
@Helthurian
@Helthurian 4 жыл бұрын
You say undeniably, but Unreal has a full fledged learning platform similar to that of a college, plus other resources. I think we should just be happy there's two engines with loads of resources at our disposal instead of devolving into tribalism.
@illsaveus
@illsaveus 4 жыл бұрын
@@Helthurian it’s not tribalism to simply have an opinion on what’s better
@MaruskaStarshaya
@MaruskaStarshaya 3 жыл бұрын
@@illsaveus you can't know what is better if never tried something else. How about Godot? Never heard about, huh? Stop being shallow.
@glassystudio
@glassystudio 3 жыл бұрын
@@Helthurian no i used unreal for 2 year , and making 2d games there is no parallax camera, like none. Unreal is great for 3d but you have to do it with blueprints that is not so flexible or vast as unity c#. In unreal if i want to script itS c++ that is absolutely hard language to learn. Plus unity is getting ECS from which its possible to play games like GTA V and other AAA titles games on your mobile phone
@glassystudio
@glassystudio 3 жыл бұрын
Plus ECS, my mind was blown when they played their demo in iphone
@lucasmercier5813
@lucasmercier5813 4 жыл бұрын
I finally understand how to use SO as event channels, ty
@vanilla-plus
@vanilla-plus 4 жыл бұрын
I honestly feel like this 'data asset' pattern is the long-term way forward for Unity, in terms of usability. Praise Ryan!
@Ziplock9000
@Ziplock9000 4 жыл бұрын
You still have to invoke and subscribe, so it can never just be data driven.
@vanilla-plus
@vanilla-plus 4 жыл бұрын
@@Ziplock9000 Yeah not purely.
@RyanGamesOfficial
@RyanGamesOfficial Жыл бұрын
Hey, really appreciate the video on architecture. I'm over here using Godot, but I find a lot of these principles are universal. It's unfortunate that the C# community in Godot isn't as developed and tends to be more hobbyist-level. Would love to see more advanced content like this. Cheers!
@xddude
@xddude Жыл бұрын
Godot as a whole is at a hobbyist level. As Clay John, the Godot rendering team leader said during his GodotCon2023 talk "Right now if you are making a small game it's extremely easy, and if you are making a huge game it's extremely hard." He also stated that's Godot's top priority is ease of use above all else. Godot is software aimed at hobbyists, it's not trying to compete with Unity and such. If you are waiting for the Godot c# community to reach higher levels you might be waiting a while because it's simply not the goal right now.
@roguestargun
@roguestargun 4 жыл бұрын
This video (particularly the section on input channels) was unbelievably useful for my project. I really struggled to scale my project due to the extreme coupling of different GameObjects via UnityEvents. Whenever this coupling occurred, the prefabs need to be locked together into a super prefab. This is also problematic since I'm making a VR cockpit with both virtual controls and gamepad or touch controller controls. After I watched this video, I spent several hours refactoring my entire codebase to make use of Scriptable Objects. Now every VR control goes into an InputChannel SO, which can have a spaceship avatar (or even enemies!) listen in on the controls. It now becomes even trivial to say, rewire the controls of the cockpit to remotely pilot something else. It's really quite an amazing pattern to learn!
@roguestargun
@roguestargun 3 жыл бұрын
One year later and I'd still say this is the most useful Unity educational video!
@SoulGameStudio
@SoulGameStudio 4 жыл бұрын
5:40 I feel like I do somewhat the same thing using a simple static class, not inheriting from MonoBehaviour. Everything in the project can access input through that static class, so I don't see the specificity of ScriptableObject here?
@r6scrubs126
@r6scrubs126 4 жыл бұрын
you're using a singleton setup then, which is what they talked about at the beginning. There's plenty of info on singleton vs scriptable objects if you do some googling for more in depth info on the pros/cons of each. I don't think you should expect scriptable objects to suddenly allow you to do something new that you couldn't do with singleton though, they're just a different way of organising things and help make things more modular and flexible
@SoulGameStudio
@SoulGameStudio 4 жыл бұрын
@@r6scrubs126 I think I heard about google before. I ask here to have the chance and the pleasure to interact with humans :) To be more specific with my confusion: the video showcases MonoBehaviour singletons, which have to be incorporated in each Scene or else scripts that need them won't work. Which is not the case with classic singletons that I use freely around. So I don't think the argument "it's scene dependent" used against singleton and in favor of SO, is valid in my situation. Unless I miss something.
@SoulGameStudio
@SoulGameStudio 4 жыл бұрын
@@CiroContinisioUnity That's right, for AudioSource I use MasterAudio so it's a MonoBehaviour singleton indeed. I still have to wrap my head around when to get advantage of the SO tho, I only use them for shared data and never put logic into them like shown in the video. Thanks for the input!
@Stinow
@Stinow 10 ай бұрын
Same here! Love the vid, but a static class works similar for me as an event bus. What would be the advantages of SSO here?
@b4Vibe
@b4Vibe 4 жыл бұрын
This is awesome. You should pay more attention to game architecture. Thanks for this one and good luck on UOP ;)
@nguyenhoangminhtrung2779
@nguyenhoangminhtrung2779 2 жыл бұрын
I love being a game dev.
@mooorphy7816
@mooorphy7816 4 жыл бұрын
Great video ❤
@aranna5372
@aranna5372 4 жыл бұрын
Can I ask you to come ant watch my Videos ? If it posible
@JayNeti
@JayNeti 4 жыл бұрын
Im not joking but this is very useful and helped a lot with my workflow.
@OnlyEsquite
@OnlyEsquite 4 жыл бұрын
Thank you. This is gold.
@LautaroArino
@LautaroArino 4 жыл бұрын
Great to have more architecture videos! But I'm not sure why SOs do that you can't do with a singleton. Maybe I looked through to fast but isn't it your design pattern that makes the architecture decoupled and not necessarily placing the event handlers in an SO?
@CSPlayerDamon
@CSPlayerDamon 4 жыл бұрын
There isn't much that SOs can do IN-GAME that prefabs can't do. SOs nowadays are more for re-usable data and editor assets, since they don't support Component based architecture like MonoBehaviour does.
@LautaroArino
@LautaroArino 4 жыл бұрын
@@CiroContinisioUnity so it's like you are using SOs kind of lika a unity dependency injection? Instead of having a DI container that you can configure to use for example different managers if you are testing or doing something else you can just switch instance of SO. As long as the fields in the SOs all have the same names. Oh yeah which they of course do cause you are using different instances of the same SO type. So this way the class that calls a handler or manager in the SO have no connection to whatever actually handles the call. It just knows there is a SO that can handle it. I think I get it and I like it.
@CSPlayerDamon
@CSPlayerDamon 4 жыл бұрын
@@CiroContinisioUnity I'm not quite suggesting that, neither am I disagreeing with using SOs that way. I just prefer using components whenever I can. For example, I'd have the AudioManager which has a field of BaseAudioChannel : MonoBehaviour or something of the like. We can also extend that class (AudioChannelSOConnector : BaseAudioChannel) to have a serialized field of BaseAudioChannelSO : ScriptableObject as a field if we wanted to go the way of SOs. As per the cross scene, in the example above, the main AudioManager class would be a singleton. All in all, I've gotten to use SOs like that in the past and I could not exactly make things as modular as I wanted. Component based architecture has helped me a lot more, since I can achieve whatever I want while also being able to use Component's class advantages.
@CSPlayerDamon
@CSPlayerDamon 4 жыл бұрын
@@CiroContinisioUnity Ah, I see. My mistake, I didn't realize, despite watching the video, that these SOs are meant for communication purposes only. Hmm, that's quite interesting actually and seems to be a very valid reason for using them. Sorry for that, I'll be watching the videos more carefully from now on!
@MidnightSt
@MidnightSt 4 жыл бұрын
I have noticed that in your official tutorial you often do "separator objects": "--------------LIGHTING----------------", and such. ...funny that you haven't thought of the feature that I'm about to suggest now: how about when one gives object a name starting with two dashes "--", it gets converted to and displayed as, proper separator? =D
@nickr9160
@nickr9160 3 жыл бұрын
Better yet, cosmetic-only folders in the hierarchy. Collapse-able without the need of any transform parenting.
@InexperiencedDeveloper
@InexperiencedDeveloper Жыл бұрын
What's the issue with making the event channels static classes that don't necessarily need to be instantiated?
@begbarros
@begbarros Жыл бұрын
adding scenes additivelly is the same as adding a singleton to a gameobject and set it to dont destroy on load. Dependency between scenes are still being created in both cases..
@999Souls
@999Souls 4 жыл бұрын
This video is HUGE! For too long i was looking for a serious large project made by people who know what their are doing so i could learn pattern and stuff, and the gods have listened!
@abdulrahmankerim2377
@abdulrahmankerim2377 4 жыл бұрын
Very interesting and useful...
@MatrixQ
@MatrixQ 4 жыл бұрын
I think this is exactly what I needed. I kind of started using SOs like this, but I didn't fully grasp what I could do with it. Thank you for this.
@AurelianoShowsTheWorld
@AurelianoShowsTheWorld 4 жыл бұрын
Unity, I love your education and your engine! Thank you a lot folks! You've changed my life!
@Ziplock9000
@Ziplock9000 4 жыл бұрын
Ignoring the use of Events/Actions for a moment as they are not exclusive to SOs anyway; Essentially you're using SOs instead of a static class that can span across scenes with the added benefit of it being a monobehavior. SOs don't solve the referencing problems you seem to imply they do at the start of the video, they just make them hard references instead of loose ones via a string. This method also adds another layer between your dispatcher and your receiver, so more objects to juggle and more complications. I still don't get why they add value with a message system above what I've mentioned. However, as data containers able to have inheritance and viewable in the inspector they are wonderful.
@bamneil58
@bamneil58 24 күн бұрын
Indeed. While the use cases being made are valid, the reasoning, software engineering wise, is often wrong, which is dangerous because it confuses beginners.
@xMarcinPPP
@xMarcinPPP 4 жыл бұрын
So basically that's quite a good way to keep the architecture of the game simple and extensible. At work we were using this solution for our project, until we had to use addressables system, which totally doesn't work with what is shown in the video. ScriptableObjects loaded via addressables are totally different instances than the ones that are put directly into the scenes or prefabs. That fact makes this solution unfortunatelly totally unusable, because instead of putting Channels into GameObjects and Scenes directly, you need to load them from addressables each time, or pass them from top to bottom - what this solution is trying to resolve. Is Unity going to do something about it, or suggest any working solutions?
@Ziplock9000
@Ziplock9000 4 жыл бұрын
I've visited SO event systems a few times and I don't understand the massive hype that surrounded it about a year ago. A static class in your game is a much more manageable way to dispatch events to whoever needs to know across scenes. Using SOs solves nothing over this and just adds more files to manage. As data containers, SO's are wonderful though.
@yamamuratatsuhiko4762
@yamamuratatsuhiko4762 4 жыл бұрын
An easy way to solve that problem is to put the scene and ScriptableObject in Addressable. You cannot refer to Addressable SO from the local scene, but you can refer to Addressable SO from Addressable Scene.
@xMarcinPPP
@xMarcinPPP 4 жыл бұрын
​@@yamamuratatsuhiko4762 The scenes were loaded from Addressables, but the behaviour was still wrong - I would have to check if what you are saying is actually right, but it makes sense.
@xMarcinPPP
@xMarcinPPP 4 жыл бұрын
@@Ziplock9000 Don't get me wrong - I'm far from saying that SO systems are the best possible architecture. It is handy especially in small and middle projects, because in larger ones when you put a reference to SO's in every single prefab it might me unmanageable later on. I still much more prefer to use some kind of Dependency Injection, and passing the right systems to the places where they are needed - and that's the solution that I've implemented when when I met the problem with the Scriptable Objects architecture.
@xandercooney
@xandercooney 4 жыл бұрын
@@Ziplock9000 Same, I'm grateful to the SO event architecture hype because it made me understand the usefulness of events as a concept, but once I learned about static events I was like... this is clearly better than SO events... I suppose they still have usefulness for letting designers create more functionality without code, but I agree that they seem to be most useful as data containers.
@falco830
@falco830 3 жыл бұрын
I started using SO’s in my NetworkBehaviors and things got really messed up! Please make a tutorial with SO’s and Network Patterns.
@Lucas-hh4oh
@Lucas-hh4oh 4 жыл бұрын
This is exactly what I need right now "Game Architecture"! Ayo thanks Unity!
@TheCodesnippet
@TheCodesnippet 4 жыл бұрын
Great great great video, thanks Unity !
@leshalozhkin
@leshalozhkin 2 жыл бұрын
I would like to know more about the sound system. Where can I find more information about such a system? 07:13 - Events for playing audio
@Gredran
@Gredran 4 жыл бұрын
Unity is so engaging. Like I love Unreal's realism, but not only am I proud of Unity for getting there, but Unity makes 2D and stylized everything so much easier for games. Keep these series up! It's so intuitive using Unity I was surprised I took so long getting started :)
@eddie.z
@eddie.z 4 жыл бұрын
I agree w/ you, one of the reasons Unity is so good is because of its user and beginner-friendly layout.
@JackFastGame
@JackFastGame 3 жыл бұрын
Nowadays Unity is able to demonstrate similar graphics level as Unreal does.
@hassankhallouf9391
@hassankhallouf9391 4 жыл бұрын
I've been using this architecture for a while now, The main drawback for this, the events lose all references if you change code at run time, which can hurt testing time
@hassankhallouf9391
@hassankhallouf9391 4 жыл бұрын
@@CiroContinisioUnity no I don't mean when I refactor, just changing code at run time will clear all registered listeners, I have to stop and play the game again
@hassankhallouf9391
@hassankhallouf9391 4 жыл бұрын
@@CiroContinisioUnity well yeah, it's minor inconvenience, but for testing, sometimes it speed things up
@hassankhallouf9391
@hassankhallouf9391 4 жыл бұрын
@@CiroContinisioUnity I'd say it's small still, going to medium size, but I usually have some testing scenes that are isolated. Say I'm working on coding a new weapon, changing code at run time can come in handy
@Ziplock9000
@Ziplock9000 4 жыл бұрын
Yeah the reference stuff he talks about is just not true. It not only does not solve the referencing issues with singletons or static management classes, but can introduce new problems that you have found. Furthermore, the information needed to re-create those references is lost as they are just NULL rather than just breaking.
@Bluequaz
@Bluequaz 2 жыл бұрын
8:20 how is this done with objects loaded in an inactive scene? DontDestroyOnLoads go in their own section. I was curious what exactly is making this happen in this case
@dagamemakar3095
@dagamemakar3095 2 жыл бұрын
10:30 have this custom inspector done in those next episodes?
@ryanlaseter7626
@ryanlaseter7626 2 жыл бұрын
Whooo that's super powerful, abstracting out the input to allow anything to listen to it. That's amazing, the subscribers don't need to know how it works/where the input vector is coming from, just that there was a movement. Nice.
@lambjalfrezi
@lambjalfrezi 3 жыл бұрын
I am writing a game which uses the scriptable object event relay and it has made a *huge* difference to the ease of understanding the code as well as the ability to minimise dependencies. I have always liked events, but as projects have got more complex the events can turn into spaghetti. Using the single scriptable object method instead has totally solved that complexity problem. I think of it as having a central event switchboard rather than individual components wired together. Thanks very much for this.
@lambjalfrezi
@lambjalfrezi 4 жыл бұрын
Thanks. These focussed videos are much more useful than the live development streams (which I find to be a bit waffley).
@JacobNax
@JacobNax 12 күн бұрын
Even in late 2024 this is till the most optimal way to make games. Forget singletons and wait more on ECS or perhaps find a way to combine this with ECS? I was wondering if you can combine DOTS + SO's with some sort of resource provisioning in initialization contexts.
@nocultist7050
@nocultist7050 3 жыл бұрын
I'm watching this a day after I figured exactly the same thing on my own XD
@tPlayerioT
@tPlayerioT Жыл бұрын
there are 2 audio listeners in the scene. Please ensure there is always exactly one audio listener in the scene.
@SMGtk
@SMGtk 2 жыл бұрын
I am real confused about this. Some are saying that the change in scriptable object is permanent, some are saying it will be reset once the editor is closed.
@GorasGamesStudio
@GorasGamesStudio 4 жыл бұрын
OMG this information challenges my entire custom event system ! I know ScriptableObject for long but just used them for data storage. So I have a few questions : Will you say that this system is efficient for events triggered every frame ? My game is event based and supported by a Singleton (not Mono) EventsManager used to trigger, add listeners, remove listeners, etc. Now I hesitate to upgrade everything to your system. But would that be an upgrade ? This is the question !
@danielr7599
@danielr7599 4 жыл бұрын
depends, if the project is in mid-late production, and its runing fine, i wouldnt change "dont fix it if it int broken" . but if its starting stages, its up to you and your time table.
@GorasGamesStudio
@GorasGamesStudio 4 жыл бұрын
@@danielr7599 oh no it's far from starting stages, and yes i decided to not change the working system. But I'll check it on a new project just starting soon !
@lazysnail145
@lazysnail145 4 жыл бұрын
dude if it works, then it works. dont chase any new shining thing. in the video they contradict themselves multiple times. so take what they say with grain of salt.
@GorasGamesStudio
@GorasGamesStudio 4 жыл бұрын
@@lazysnail145 Yes but always looking for a better solution, more efficient. How did they contradict themselves ?
@lazysnail145
@lazysnail145 4 жыл бұрын
@@GorasGamesStudio 1. They say if you want test prefab which uses say Audio singleton to play music, then there is dependency. Logically thinking if your object uses some external audio system to play sounds, it already has dependency on it singleton or not. For the very bad example they showed with AudioManagerExample there is multiple ways to test this prefab without any problems, they can create singleton dynamically, they can check if singleton exists in the scene and ignore sound part of the prefab or they can move sound play functionality inside prefab. 2. Every scene in their project have initialization block with pretty much singletons that manage state of the game. 3. Even this small project is mess with i dont know how many different SO everywhere and its impossible to follow whats going on in it. When project is way bigger they many end up with many 1000 of different SO, this is nightmare to manage. 4. Your IDE pretty much useless when everything is setup outside code, you cant follow the code because there are no references . 5. If you ever checked source code of unity game from steam pretty much all of them heavily use singleton pattern without all this overcomplicated engineering.
@DePistolero
@DePistolero 4 жыл бұрын
Great work, started basing everything on scriptable objects, events, data, whole saving system. Thanks for the series. Editor scripts are really useful. Been using Singleton and hard references, but the project gets impossible to scale. Focusing on actual game architecture, flow, best practices but on macro level like this would be awesome.
@neverstepd7
@neverstepd7 2 жыл бұрын
This is just perfect, I wanted to keep a list of spawnable enemies but the problem is that I needed the singleton, but thanks to your tutorial I can now have an internal list without ever having to spawn it
@aranna5372
@aranna5372 4 жыл бұрын
Thank you for your Great Engine
@alih84411
@alih84411 4 жыл бұрын
very good 👍
@Ironlionm4n
@Ironlionm4n 2 жыл бұрын
This is why I love Unity, they have great educational tools which invigorate my excitement in game development
@hosseinse4079
@hosseinse4079 3 жыл бұрын
useful video from unity
@containedhurricane
@containedhurricane 3 жыл бұрын
The architecture is great for modularity, but what about the memory garbage generated by Unity Events? Why not use ECS instead?
@eknuds
@eknuds 2 жыл бұрын
Would this technique be suitable for disseminating data from the network?
@hasnainfareed8555
@hasnainfareed8555 2 жыл бұрын
How did that initialization scene work, How did it stay when other scene was active ?
@snaileri
@snaileri 7 ай бұрын
The initialization scene is unloaded only after the persistentManager scene has been loaded.
@Bravehearte
@Bravehearte 4 жыл бұрын
The project is really taking form! This series is becoming very interesting to watch and I am also loving to follow the development of the project.
@toninotonnato7776
@toninotonnato7776 2 жыл бұрын
All content creators making tutorials should learn from this video: pace, snippets, diagrams, increasing complexity. Just perfect, well done Unity guys!
@linnosmg
@linnosmg 2 жыл бұрын
AudioCueEventChannelSO _audioCueEventChannel = default; What does the default mean? Does it choose some sort of default value or in this case SO that you set?
@Hdjsjxbnskux
@Hdjsjxbnskux 4 жыл бұрын
This video is nice.
@aranna5372
@aranna5372 4 жыл бұрын
Yes It was nice and Useful
@juampyvarela
@juampyvarela 3 жыл бұрын
Got a question here. I started implementing this pattern and found out that, when changing scenes, the references persisted. I have been trying to use UnityEvents, wich flush on scene change, but can't make them work as generic as with Actions/UnityActions. For now, I have an abstract class that contains the flush method and inherits from scriptableobject, then I just use the resources method to find all implementations. But my question is, is there a better way to do this? Again, my problem with UnityEvents is that I have to make an implementation for every combination I need and that's messy.
@juampyvarela
@juampyvarela 3 жыл бұрын
@@CiroContinisioUnity I didn't want to rely on every subscriber having to control their unsubscription. But that may be the only way since, as you pointed out an I didn't realize, when a subscriber is disabled in the scene, the reference will hold.
@juampyvarela
@juampyvarela 3 жыл бұрын
@@CiroContinisioUnity And thank you for the answer ❤️
@eifet
@eifet 2 жыл бұрын
@@juampyvarela I would say you need to do that. In my experience it's the correct way of coding. You need to do stuff on start and then you always need to think, what happens, when object is destroyed (or disabled). So you will always have a closed lifecycle. And this way you will always be sure that every time you create/activate, then destroy/deactivate and then again creating/activating a piece of code, it will work the same way every time. Because, for example, you initialize everything OnEnable and reset everything OnDisable
@yudanaim6849
@yudanaim6849 Жыл бұрын
Doe's scriptble objects remember change from scene to scene in build?
@snaileri
@snaileri 7 ай бұрын
Yes
@brockemon
@brockemon 4 жыл бұрын
Excellent
@ThomasChen-ur2gt
@ThomasChen-ur2gt 4 жыл бұрын
Will you say that this system is efficient for events triggered every frame? I had a performance problem once when I tried to send events every frame and then assumed events are not efficient on a per-frame basis.
@Ziplock9000
@Ziplock9000 4 жыл бұрын
It's best not to use event systems when something is called very frequently but instead call directly on the method. Personally, I'd consider 60fps too often.
@zionen01
@zionen01 3 жыл бұрын
Nice video, it makes it easier for anyone who wants to jump into the open project mid-way. The open project has proven to be a wealth of useful information on game development, very useful.
@GameDevExperiments
@GameDevExperiments 4 жыл бұрын
Top quality content! A must watch for anyone who wants to make their game in a scalable way .
@kuchbhi8363
@kuchbhi8363 4 жыл бұрын
When did Bolt 2 coming
@StefanLopuszanski
@StefanLopuszanski 4 жыл бұрын
It isn't. Bolt 2 was canceled and instead they are focus on Bolt 1 =/
@aranna5372
@aranna5372 4 жыл бұрын
Playmaker is far better
@StefanLopuszanski
@StefanLopuszanski 4 жыл бұрын
@@aranna5372 : What? Playmaker is an FSM... it isn't a visual scripting tool.
@aranna5372
@aranna5372 4 жыл бұрын
@@StefanLopuszanski its True Buts difrent betwin them ?
@StefanLopuszanski
@StefanLopuszanski 4 жыл бұрын
@@aranna5372 : They are completely different tools. While Bolt has a Finite State Machine, like many visual scripting tools, it isn't designed for that first and foremost. They are very different. Look up "NodeCanvas" (Playmaker competitor) and "FlowCanvas" (Bolt competitor). They are both by the same company, can work together, but do very different things.
@eterlan2538
@eterlan2538 3 жыл бұрын
omg, this is exactly what I expect to learn how to make a game! Thank you guys so much! I love this kind of easy-to-learn game architecture!
@VladimirEmelyanov
@VladimirEmelyanov 3 жыл бұрын
Thank you! In this project are a lot of interesting information to get new skills and approaches. I'm glad to read this code and explore it everyday. Keep in mind, that skill of code reading and understanding is the most required skill as you can recieve!
@Joserbala
@Joserbala 4 жыл бұрын
I don't get the difference between this and plain C# classes, someone could explain please?
@GuillaumeKehren
@GuillaumeKehren 4 жыл бұрын
POCO's don't exist as assets that you can plug around using the inspector, so you have to wire everything by code instead of leveraging the Unity Serializer magic
@Joserbala
@Joserbala 4 жыл бұрын
@@GuillaumeKehren oh, I see. And what about putting a POCO as Serializable and inserting in a Monobehaviour? I'm only two months into Unity hehe
@GuillaumeKehren
@GuillaumeKehren 4 жыл бұрын
@@Joserbala its very useful at times to lay down data like this but it serves a completely different purpose, that POCO instance cannot be shared throughout several objects /prefabs/scenes at edit time, its like asking "what about using breaks instead of tires in a car", those 2 things are necessary and perfectly valid for their own purpose but cannot do the other's job ! And for that matter, at some point you'll probably end up with POCOs serialized in your SOs ;)
@Joserbala
@Joserbala 4 жыл бұрын
@@GuillaumeKehren oh, I see! Thank you so much! :D
@BarcelonaMove
@BarcelonaMove 4 жыл бұрын
You are doing a great job with this series. Keep it up!
@fabiofrancone
@fabiofrancone 4 жыл бұрын
I'm sorry guys but this video kinda confirms Unity's philosophy of selling solutions that look easy and shiny without teaching people about the actual cons. They start the video telling about the cons of the singleton pattern saying that you have to recreate the whole game logic in the scene just to test a single functionality.. their solution though is to basically recreate singletons using scriptable objects so the same problem exists only it is hardwired outside the scene so you get the illusion that you've solved the problem while in reality it is still very much there only in a different place. Plus they claim that this solution scales for big projects but they fail completely to mention the deserialisation and loading costs that having hundreds of scriptable objects would bear on a large project leading to impossible loading times and memory costs! They scratch the surface of the maintenance complication of having a large number of small scriptable object assests and only give a hint that you end up with the same spaghetti mess of using singletons (because they are using them as just another flavour of singletons!) This video is terribly misleading and simplistic in my opinion . It would be totally fine if they said : look this is a beginner video and it is fine for small projects, if you want to use this approach for mid sized or larger projects you should thing twice because of this and that performance and memory reason and this and that code architecure and scalability reason... the only added value of this approach to me is that you get a way to have modular singletons.. maybe useful, but at what cost? They fail to mention
@cfffba
@cfffba 4 жыл бұрын
No. They actually solved the con they were talking about, it's not an "illusion". If your prefab's scripts are calling into a bunch of singletons, you can't test the prefab in isolation in an empty scene; you have to put all the singletons in the scene as well. Which is not the case with a loosely coupled solution in which all you're doing is raising events. They're not using "another flavor of singletons", they're using classes that communicate between each other via event channels. That's not even remotely similar to singletons. There's no global access, no dependency hiding, and no single instance requirement. Of course there are drawbacks to this solution too (as always): I'd say the main issue with it is that this kind of coupling might be a bit too loose - it adds an extra level of indirection and makes it harder to reason about the program flow, you can't see what functions are being called and in what order just by looking at the code. All you know is you're raising an event. But I don't agree with your objections about "impossible loading times and memory costs" at all. Replacing several monobehaviour singletons with scriptableobjects won't have any noticeable performance implications, of course.
@WyMustIGo
@WyMustIGo 3 жыл бұрын
There is no problem with the singleton pattern, the problem lies in your misuse of the pattern. Boy this video reminds me of the academics who never wrote a single line of commercial game or application code telling others theory that they do not understand themselves.
@JackFastGame
@JackFastGame 3 жыл бұрын
So what's the right approach of using singleton?
@el_primer_y_el_ultimo_caiman
@el_primer_y_el_ultimo_caiman Жыл бұрын
​@@JackFastGame a SO is literally a singleton. literally all this is is avoiding the S word and replacing it with another S word, except this one binds your code to their tech so it's harder to refactor your game or run away to another engine. totally baffling
@JackFastGame
@JackFastGame Жыл бұрын
@@el_primer_y_el_ultimo_caiman It's not a singleton by any means. Simply because you can create many instances of SO.
@denisgoodman4492
@denisgoodman4492 3 жыл бұрын
Strange implementation the Singelton in the Awake(): ... _instance = GetComponent(); ... if (_instance = null) return; These lines change nothing??? :) But also change nothing corresponds to aim of this video - SO is very Helpful
@felipejhony6039
@felipejhony6039 9 ай бұрын
Im still trying to understand why create a scriptableobject to read inputs when you can easily add a movement script component to the protagonist. Sorry im dumb.
@snaileri
@snaileri 7 ай бұрын
Because the protagonist might not be the only object in the scene that reacts to input.
@felipejhony6039
@felipejhony6039 7 ай бұрын
@@snaileri I see, good point
@s0sDarkAngels0s
@s0sDarkAngels0s 4 жыл бұрын
Thanks for the video. This will be a great help on my journey in Unity
@noodle-eater
@noodle-eater 4 жыл бұрын
Thanks, guys that's awesome, I've been wondering what architecture I should use.
@Devsplorer
@Devsplorer 3 жыл бұрын
I like using SOs as changeable data containers but as channels, wow I like the approach 🤩 I just need to experiment on it to understand it better for future uses. Thanks for the tutorial 🌟
@fredg697
@fredg697 2 жыл бұрын
Great tutorial. However a better approach would be using a dependency injection system like extenject
@mr_star75
@mr_star75 4 жыл бұрын
NICE
@labacademia_jL
@labacademia_jL 4 жыл бұрын
we need to make spanish localization a thing
@RimuruDev
@RimuruDev 2 жыл бұрын
❤️
@Thephoenix777
@Thephoenix777 2 жыл бұрын
I really wish they would come up with a Dependency Injection solution instead of making people jump through hoops to provide services. I've been a full stack developer for 10 years, and one of the most baffling things about unity is its inability to conform to industry best practices. Utilizing SOLID principles is a huge pain with unity. Once I picked up Zenject (A IOC framework on the asset store for free). It made a world of difference. SO's are nice to use in certain places, but honestly it still looks like there's way to much dependency on a team of devs knowing which SO to drag into which game object. What's shown here works for a smaller game, but imagine having to track down every little game object to ensure its wired to everything correctly, instead of lets say, injecting an eventListener service in your C# that you can call in code and leave it at that. Seriously, after installing Zenject, I was able to refactor my entire code base, dropping thousands of lines of code, and making it easily maintainable. Its sad that I have to go through a 3rd party asset to do something in C# that at this day and age any mid level c# developer should be doing.
@onionchickshow7660
@onionchickshow7660 4 жыл бұрын
почему вы закрыли проект battle of zombies?😢😭
@MacMiggity
@MacMiggity 3 жыл бұрын
These tutorials are REALLY GREAT Unity! Please keep doing these with advanced topics!
@plokkum
@plokkum 3 жыл бұрын
I always used SO's just as data containers with minimal functionality. Never thought of using it in this way. That's pretty clever.
@knockknockp
@knockknockp 3 жыл бұрын
wish i knew about thid ealier
@FullMe7alJacke7
@FullMe7alJacke7 2 жыл бұрын
🤯
@rafarodriguez4765
@rafarodriguez4765 2 жыл бұрын
One of the most useful Unity videos in a lot of time
@FunNooberCodingForBeginners
@FunNooberCodingForBeginners 3 жыл бұрын
This was actually very informative! Thanks! I have always wondered how to escape singletons! This is what I was looking for!
@elbow005
@elbow005 4 жыл бұрын
What's chop-chop?
@elbow005
@elbow005 4 жыл бұрын
@@CiroContinisioUnity nice, thanks
@2dinunity10
@2dinunity10 4 жыл бұрын
cool.
@kaasronald3623
@kaasronald3623 3 жыл бұрын
I get the problem with singletons, but what about static classes? Setting up references to scriptable objects for every class & every prefab that has that class (let alone null checking the references for when you edit the code during runtime), it seems incredibly time consuming in the long run.
@samuelthibodeau8272
@samuelthibodeau8272 2 жыл бұрын
I'm coming from a native mobile background and I love this. I want to make a 2d game while implementing similar architecture.
@content9210
@content9210 4 жыл бұрын
Pls add Unity for linux chromebook so I can do my game dev
@NotASpyReally
@NotASpyReally 4 жыл бұрын
Wow this is all too advanced for me. I hope I learn to do this soon! It sounds amazing!!
@teknikoscave
@teknikoscave 2 жыл бұрын
Another abandoned project from Unity. The list just keeps growing.
@specter99
@specter99 4 жыл бұрын
A question: I want to get into unity but I don't want to steal other peoples resources, How do you make your own or hire someone to make an object
@TK-sr2hz
@TK-sr2hz 4 жыл бұрын
An object?
@specter99
@specter99 4 жыл бұрын
@@TK-sr2hz textures for like a mirror for example with reflection, how do you go about hiring someone to make that or finding a tutorial/guide on things like that
@TK-sr2hz
@TK-sr2hz 4 жыл бұрын
@@specter99 u can watch videos on how to do that or go on 3D forumns to hire people. Or literally any other social media platform
@abdou023
@abdou023 3 жыл бұрын
So, Mixing ScriptableObjects with the Observer pattern is how Unity recommends games should be developed. I wish there was a full tutorial for a complete project for that.
@FaviMarzo
@FaviMarzo 4 жыл бұрын
Milk Oh wait wrong channel
@Hello-qg4yk
@Hello-qg4yk 4 жыл бұрын
Karlson
@fr4ctur71
@fr4ctur71 2 жыл бұрын
Been using unity for a little bit now as I learned coding and my friend and I use So's quite a bit in our projects and I was curious what the purpose of using them as channels instead of standalone objects is. For instance, your input system is an SO that contains all the interfacing and actions needed for doing its job. Your audio and scene loading systems, however, exist on monobehaviours and and use channels to give and receive information. In our projects we have simply made these systems entirely as SO's and plugged them into whatever needs access to them. As i said, I'm by no means a trained developer and could be missing something simple. I know monobehaviours have access to different things like update and fixedupdate while SO's dont. Is there another reason to use this pattern?
@megatronusv2215
@megatronusv2215 2 жыл бұрын
pub-sub, nice!
@elfetus3915
@elfetus3915 4 жыл бұрын
I am 907.001 subscriber 😅
@screenapple1660
@screenapple1660 4 жыл бұрын
Is there an existing GTA like open project? I mean I don't want to end up like Cyberpunk 2077 fans complain. bad graphics load, physics, and glitches.
@D-TroS
@D-TroS 2 жыл бұрын
Just use statics.
The Ultimate Introduction to Scriptable Objects in Unity
20:45
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН
Watch This Before Working on a Big Game in Unity
18:44
John Leorid
Рет қаралды 301 М.
The 6 Design Patterns game devs need?
24:20
Jason Weimann (GameDev)
Рет қаралды 375 М.
Unity Architecture for Noobs - Game Structure
16:24
Tarodev
Рет қаралды 208 М.
Unite Austin 2017 - Game Architecture with Scriptable Objects
1:04:29
Handling complex input | Open Projects Devlog
9:41
Unity
Рет қаралды 31 М.
Scriptable Objects: What are they? How do you use them?
10:38
Software Architecture in Unity
7:13
Jason Storey
Рет қаралды 123 М.
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН