Learn to Build an Advanced Event Bus | Unity Architecture

Описание к видео Learn to Build an Advanced Event Bus | Unity Architecture

Decouple your Game Objects! Create a powerful Unity Event Bus that bootstraps itself at runtime using advanced C# and Unity techniques. Discover how to execute code before your scenes load and search Unity assemblies for your code. This video will help you take your skills to the next level, even if you feel like you are still a beginner!

A custom Event Bus is great for larger or more complex projects where decoupling is essential. It helps in organizing code in a way that various parts of your system can communicate without needing to reference each other directly. This way, you can change one part of your system without having a domino effect of changes across the codebase. It can help in categorizing events, logging, and even debugging to some extent by providing a clearer overview of what's happening in your game.

Advanced Topics:
RuntimeInitializeOnLoadMethod
InitializeOnLoadMethod
Type.MakeGenericType(T)
Unity Predefined Assemblies

Many people have asked, 'Why not create an EventBus at runtime instead of bootstrapping?'

Instantiating static classes in C# has some overhead, so if you have a lot of different Events it can be beneficial to create all your Event Busses ahead of time and avoid potential problems during gameplay. Additionally, it allows you to efficiently create a list of all Busses so that you can clear statics when coming out of Play Mode, something that is not guaranteed by Unity when Domain Reload is disabled, and can cause strange behaviour and memory leaks. Furthermore, you may wish to clear them anytime, or perform other debugging or diagnostics on all instances.
See the bit about Unity statics here:
https://docs.unity3d.com/Manual/Domai...

🔔 Subscribe for more Unity Tutorials    / @git-amend  

#unity3d #gamedev #indiedev

▬ Contents of this video ▬▬▬▬▬▬▬▬▬▬

0:00 Unity Event Bus
5:00 Assemblies Utility
8:35 Event Bus Bootstrapping
11:30 Event Bus in Action!

Source code: https://github.com/adammyhre/Unity-Ev...

Extension Methods and Utils
https://github.com/adammyhre/3D-Platf...

Assets Shown In This Video (Affiliate Links)
Odin: https://assetstore.unity.com/publishe...
Dungeon Mason Tiny Hero Duo: (FREE): https://assetstore.unity.com/packages...
Chromisu: Handpainted Forest MEGA Pack https://assetstore.unity.com/packages...
VFX Trees: https://assetstore.unity.com/packages...
Kronnect Liquid Volume 2: https://assetstore.unity.com/packages...
Kronnect Cloud Shadows: https://assetstore.unity.com/packages...
Kronnect Beautify: https://assetstore.unity.com/packages...
Kyeoms Hyper Casual FX 2: https://assetstore.unity.com/packages...
MalberS Animations: Forest Golems: https://assetstore.unity.com/packages...
Archanor VFX Portals: https://assetstore.unity.com/packages...
SineVFX: Better Crystals https://assetstore.unity.com/packages...

Unity Documentation on Predefined Assemblies: https://docs.unity3d.com/Manual/Scrip...

Follow me!
https://linktr.ee/gitamend

Комментарии

Информация по комментариям в разработке