The main issue I see with this approach is the number of scriptable objects you then have to create and fill your project with, one for every single event you could need. You mention when reaching for a static class it's because you want something fast, not scalable, but I look at 100s of potential scriptable object event channels and see that is not scalable. Really surprised you went from an event bus to this, but I get the rationale, just not the solution. Good video, and great way of explaining generics. Never seen it explained that hand-holdy before, and I'm sure it helped someone stuck on the concept
@davidschmitt92106 ай бұрын
Great tutorial! I really liked that you offered both a code-driven approach and an inspector driven approach. The 2017 Unite talk is geared toward studios that have dedicated designers with an emphasis on inspector use. Your guide is very balanced, showing how the inspector setup is an optional step beyond what can already be done in code! Thanks so much 😁
@4rcant6 ай бұрын
I'm having nightmares trying to make everything "open-close", and this video just scratch that part of my brain. thank you
@halivudestevez26 ай бұрын
do not get fooled by SOLID princibles. They are told to be "clean code" tools, but in real life, you just get confused. I don't mean it is completely useless, or harmful, but keep your eyes open, and ask questions if it is useful in you case, or rather makes things complicated.
@zivv11476 ай бұрын
I really like your tutorials. They are of the best ones out there. I want to add a wishlist to your tutorials - that you will make a tutorial about google analytics (Firebase). That is how to to setup custom events with parameters, how to test its working, etc. I've been searching for ages and still haven't found good and up-to-date tutorials about it.
@kantagara6 ай бұрын
Awesome video. I think the best one I've seen so far in regards to Event Bus being more designer friendly :D
@dreamisover98136 ай бұрын
I've been using something similar - just in code without scriptable objects. But it has been really convenient for decoupled logic and avoiding logic from breaking when certain other objects don't exist in the scene
@Sethizback16 ай бұрын
Thanks! A very helpful example of using static classes. In my project individual units had to be registered with appropriate manager classes on enable and that caused a lot of headache to manage. I will try to move most of this logic into the event bus system you've explained and hopefully adding more particle and sound effects events in the future will be much easier. The TODO list keeps growing, no matter how many refactoring passes I do...
@LlamAcademy6 ай бұрын
Make sure the refactoring passes are helping you deliver value to your game. Eventually "good enough" has to be good enough and move on 🙂.
@andrewz87632 ай бұрын
Should the Event bus itself be a singleton implementation instead of just static since static classes aren't guaranteed to be thread safe?
@ishikindofyouknowwhat5 ай бұрын
Very clear video, now, im starting to understand but I still wonder if story driven dialogues should be handled by events too? Like lets say a character which has different dialogue based on game advancement?
@ragerungames6 ай бұрын
great tutorial. nice and easy to understand. thanks
@publicmmi6 ай бұрын
Like always, a great video! Thanks :)
@LlamAcademy6 ай бұрын
Glad you liked it 😁
@joaopedromonteiro25176 ай бұрын
In a real world scenario, would you use this buses only in events that connect different systems/unrelated parts of code? I do use a lot o Actions in my code, and many of those are to bind together closely related scripts, like the Player triggering some small events that are used in other scripts of the same hierarchy. In these it seems like it'd be and overkill to create all those classes.
@LlamAcademy6 ай бұрын
It depends on the complexity of your game. If what you have is working well and scales to the level you need it, you're good! If you find out some of those events need to be listened to by other scripts, you may consider refactoring those to a global event bus with one of these 3 methods.
@raymk5 ай бұрын
My problem with Event Bus is that everything can call everyone at any time. Being able to call any method through an event is super convenient and helpful for designers, however it's easy to lose track of which system should only talk to which system. If everyone can talk to anyone, there's not much incentive to keep the Enemy system only influence the enemies and not any random experience bar.
@halivudestevez26 ай бұрын
I'm trying to avoid assigning events in inspectors: these assignments are easy to loose, they also fall apart if you add more parameter to the event. They are also untrackable, and hidden from the code aspects: you cannot track doen, why that event happens. I ban UnityEvent-s from my code as much as possible, and go by System.Event. More stabile.
@halivudestevez26 ай бұрын
I have many criticizm about this approach, since I solodev and has negative, real-world experiences...
@LlamAcademy6 ай бұрын
Yup. If it doesn’t work for you and your workflow, don’t use that approach!
@sadbuttrue6666 ай бұрын
@@LlamAcademy Shouldn't it be quite easy to solve the problem with the messaging approach? It would only be necessary to insert a message in the base class, which is given to each event and can be read at a suitable point. I currently use the signal system from DoozyUI and it does exactly that. Each event also has a message payload. There is then the SignalConsole and the StreamsConsole in which all fired events are displayed.
@Briezar6 ай бұрын
I have the same approach as yours; if there's a Button component that needs to register click events, I'd create a reference to that Button and hookup from code instead. But then I am a programmer, I have the option to do that. It doesn't apply to designers who shouldn't be touching any codes.
@aarndal906 ай бұрын
@@halivudestevez2 I think that's the most important point. I am totally with you. C# events are definitely the better approach to keep a better overview and not lose references. But using Unity events/event management via the Inspector also allows game designers and other disciplines in larger teams to make changes without having to intervene directly in the code, which is something you absolutely want to avoid as a game programmer ^^
@dbweb.creative6 ай бұрын
Can you please make a video about saving/loading player inventory, where items are ScriptableObjects. I understand that one way to go about it is - items have to be serialized by their guid or by some sort of another id, and then maybe lookup tables or something. This way there needs to be a way to scan and add SO items to lookup table in the first place... Basically I don't know which way to go about handling this whole topic, please ponder this topic in a video, thanks.
@sealsharp6 ай бұрын
Here's my "scan for all ScriptableObjects of a type" method. public static List GetAllInstances() where T : ScriptableObject { return AssetDatabase.FindAssets($"t: {typeof(T).Name}").ToList() .Select(AssetDatabase.GUIDToAssetPath) .Select(AssetDatabase.LoadAssetAtPath) .ToList(); }
@dibaterman6 ай бұрын
Sadly Godot doesn't have static actions or delegates, in there we use signals which are really convenient in their own right. I had made an event bus and made a event system which all signals emit a object Event which contains a type String and variant data (dynamic data). This isn't too bad but in bigger projects I am thinking this isn't good. So I was thinking of going with exposing the event bus via using Resources (Scriptable Objects) and putting a signal in that. Not sure... Regardless another neat thing is a broker pattern where you can get back the other end of this system, this allows for sending lamda's to handle logic inside of a broker which works independently of the origin or even the thing using the broker. So if I have say Attack and it's 0 at base but I equip a sword with 8 attack, the attack getter simply needs to return broker and whatever identifier the parameter is subscribed with to return 8. This stacks with all modifiers and I can even get a list of all modifiers and their sources since the broker knows all XD. I recall in Unity not enjoying the event channel workflow, it made it feel like drag n drop hell.
@SunSailor6 ай бұрын
If working in a bigger team, you must even expect team members, who refuse to touch prefabs, scriptableobjects or such at all.
@SebastianZoellner6 ай бұрын
It is not entirely clear to me what the benefit of using a events bus is over using the standard system events.
@LlamAcademy6 ай бұрын
What do you mean the “standard system events”?
@dunglevan3916 ай бұрын
Are there any differences between Event Bus and Scriptable Object Event Channels ?
@LlamAcademy6 ай бұрын
Yup that’s discussed in here
@kadircalloglu28486 ай бұрын
its look like zenject event system
@tufanaydin63406 ай бұрын
Thanks Liaaaaaaam
@halivudestevez26 ай бұрын
why SciptableObject for this? I have a MonoBehaviour for eventbus, for LevelEvents.
@LlamAcademy6 ай бұрын
Why do you need a MonoBehaviour for this? You do not need a GameObject nor the lifecycle methods like start/awake. 🙂 there are many ways to approach a problem. In this video I show a typical standard C# one, and two that Unity themselves have suggested in their e-book.
@RimuruDev6 ай бұрын
Cool
@Daeniak6 ай бұрын
Bread
@sealsharp6 ай бұрын
🍞
@Daeniak6 ай бұрын
@@sealsharp Bread
@franciscooteiza6 ай бұрын
How old are you? Maybe 30 or 35? You can't have more than 20 years of experience as a programmer.
@halivudestevez26 ай бұрын
he worked overnight, too
@LlamAcademy6 ай бұрын
Well if we take either of those numbers 30-20 = 10. There are plenty of kids programming at 10. 35-20 = 15, people are taking boot camps at that age. I started programming in the late 90s with Visual Basic.
@Fire-Pixel6 ай бұрын
FIRST :)))))
@LlamAcademy6 ай бұрын
😎
@jackblack98723 ай бұрын
tutorial on how to make your game impossible to remove from the unity game engine. 🤣🤣🤣
@halivudestevez26 ай бұрын
you just overcomplicate simple things.
@halivudestevez26 ай бұрын
sounds great for the first glance, but in real, it's bullshit. Bus< ??? you have to find out, look thru your 1000 code finding out what to write here. While "Bus.
@EmilM-pb2hnАй бұрын
@@halivudestevez2 Just say you can't code man. Its kinda evident