Using Blob Assets for Central Data Storage in Unity ECS - DOTS Tutorial [ECS Ver. 0.17]

  Рет қаралды 7,710

Turbo Makes Games

Turbo Makes Games

Күн бұрын

❗❗ Caution: This video was made with an older version of ECS. See pinned comment for further Details ❗❗
📌 Download the full project files: tmg.dev/BlobAssets 📌
👨‍💻 Code/Scripts from this video: tmg.dev/BlobAssets-Code 👨‍💻
💬 Come chat with other DOTS/ECS devs: tmg.dev/Discord 💬
🚧 Resources Mentioned 🚧
- Code Monkey video on Blob Assets: • What are Blob Assets?
- My Singletons in ECS video: • How to Use SINGLETONS ...
- My Change Filters in ECS video: • How to Use Change Filt...
💻 My Game Development Setup: tmg.dev/GameDevPC 💻
📸 My Camera Gear: tmg.dev/CameraGear 📸
🎮 Let me know what other topics you want to learn about 🎮
⌚ Time stamps for key topics ⌚
- 0:00 - Blob Assets in Unity ECS
- 1:24 - What are Blob Assets
- 3:15 - When to use Blob Assets
- 4:45 - Overview of Blob Asset Creation
- 6:14 - [Tutorial] Unity Project Overview
- 6:53 - [Tutorial] Create the Structure of the Blob Asset
- 8:29 - [Tutorial] Creating a Blob Asset Array
- 9:53 - [Tutorial] Creating a Blob Builder
- 10:53 - [Tutorial] Calling the ConstructRoot Method
- 11:39 - [Tutorial] Allocating Memory for the Blob Asset Array
- 12:06 - [Tutorial] Populating the Blob Asset Array
- 13:17 - [Tutorial] Creating a Blob Asset Reference
- 15:07 - [Tutorial] Accessing Blob Asset Data
- 16:36 - Final Demonstration
- 17:47 - Summary and Wrap up
🌐 Find Me Online! 🌐
📄 Blog: tmg.dev
👨‍💻 GitHub: github.com/JohnnyTurbo
🎮 Games: johnnyturbo.itch.io/
🦅 Twitter: / turbomakesgames
📺 Twitch: / turbomakesgames
🎵 Music by: Joakim Karud / joakimkarud
#️⃣ #UnityDOTS #UnityECS #MadeWithUnity

Пікірлер: 36
@TurboMakesGames
@TurboMakesGames Жыл бұрын
❗❗ *Caution:* This video was made using an older version of Unity ECS. While the core concepts remain the same, some of the API and workflows have changed as of ECS version 1.0. I would recommend checking out my ECS 1.0 tutorial video for a good overview of the latest standards for Unity’s DOTS: kzbin.info/www/bejne/f4CZkGmPlL6Imqc Once again, the theory behind the concepts of this video are still relevant, however the API has changed. Stay tuned for further updated videos on this subject. Please let me know if you have any questions either here or in our Discord community: tmg.dev/Discord
@LukeClemens
@LukeClemens 2 жыл бұрын
Sweet!! I always wondered what those blob assets were all about but never got around to figuring them out. Also I learned something new about C#'s "using" keyword.
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
Yeah definitely! I feel like blob assets are one of those topics that sound a lot scarier than they actually are - especially once you start to use them, they make a whole lot more sense.
@Forjugadname
@Forjugadname 2 жыл бұрын
I am glad I watched this vid even though I thought I new how to use blob assets as they seem way easier to create and assign to now.
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
So glad to hear this! I always find it so valuable to watch tutorials on things I think I already know pretty well - a lot of times I find I end up filling in gaps in my knowledge I didn't even know I had
@FlipYourLearning
@FlipYourLearning 2 жыл бұрын
This was definitely harder than other concepts and I will need to practice with them to completely wrap my head around the concept and all the steps needed to use them, but they do seem useful. Thanks for the tutorial.
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
Yeah this is definitely a tough one to wrap your head around at first, I think a lot of the boilerplate code makes it seem more confusing than it actually is. Once you use them to solve a practical problem, they make much more sense.
@Songfugel
@Songfugel 2 жыл бұрын
Thanks for this video, I had to return to this topic after a years pause, and couldn't for the life of me remember how I had done it in my previous projects. Such a huge struggle to get the most simplest of tasks a programmer does in a matter of seconds, oh the things we do for that little bit of extra speed and efficiency
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
Hehe, glad you liked the video. Stay tuned for some time saving ways to reduce the amount of boilerplate code I write in ECS... 😉
@NomortaL
@NomortaL 2 жыл бұрын
I know the lines get long, but don't be afraid to declare the type of variable. It makes it easier to understand instead of using 'var' everywhere
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
Appreciate the feedback, will take this into consideration, cheers!
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
Hey all! I know this video is a bit more code-heavy than normal and you don't see a whole lot going on in the Unity editor, so I hope it is easy enough to follow along with. As always, please let me know if you have any questions on this! Happy Blobbing 👽
2 жыл бұрын
I wonder why they didn't make an editor version where you create blob assets just like scriptable objects. It's as a replacement of SO I would like to use this anyway but it becomes very tedious when you need to convert SO with a million steps.
@LukeClemens
@LukeClemens 2 жыл бұрын
@ Hmmm... that's a pretty cool idea. I wonder if anyone has tried to make a plugin/package for unity editor to do that.
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
@ Exactly what Luke said, seems like a great idea for a custom editor tool 😊
2 жыл бұрын
@@TurboMakesGames I think it should be doable with the same codegen method they used for authoring components, right? Or am I missing something? Seems strange they didn't just do it if it was that simple..?
@calccalccalc
@calccalccalc 2 жыл бұрын
Hey Turbo! I suggest doing some ECS/DOTS for UGUI. Would be super useful.
@garryguan7115
@garryguan7115 2 жыл бұрын
Keep it up. Love your videos :). I feel like this talk could have paraphrased the documentation rather than explaining each concept one after another, verbally. Overall, great video my guy.
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
Appreciate the feedback, always looking for ways to improve these videos. Glad you enjoyed 😀
@wlsmdltn
@wlsmdltn Жыл бұрын
Thank you sooooooooooo much. May someone think it isn't nessasery. But if you wanna change SphereCollider or else basic collider, you should use this.
@TurboMakesGames
@TurboMakesGames Жыл бұрын
Yes, DOTS colliders use blob asset references!
@LukeClemens
@LukeClemens 2 жыл бұрын
What are the advantages of using a blob asset vs an ordinary singleton entity that you only ever read from? If you only ever read data from the singleton entity's components wouldn't it be equally as fast? I suppose a blob asset would guarantee that you don't accidentally write to it, but it seems like that's a pretty minor issue compared to all the extra code required for setting up blob assets. I think the would both use the same amount of memory. Thoughts?
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
Good question, performance-wise yeah, they're probably about the same. The thing you get with blob assets is "guaranteed" immutability, meaning the data is guaranteed to be able to be read from multiple systems/jobs/threads at once. I say guaranteed in quotes as you can do things like I did in my game of life where the blob asset pointed to entities, and while the entities stayed the same, the components on the entities didn't have the same guaranteed immutability. With a singleton you're only reading from, it's like a pseudo-guarantee, where you know that as the developer know that it will never change, but there are no built-in safety systems to prevent you from doing this. Only other thing I can think of right now would be blob arrays, but you could use something like dynamic buffers on your singleton
@ciberdead9301
@ciberdead9301 Ай бұрын
Hi, i've got a question, how would you do the construction of the blob asset in a baker, because whenever i'm trying to do this, when i'm allocating the reference to an entity in a baker i have a leak warning from unity
@starburstdragon
@starburstdragon 2 жыл бұрын
So this kind of data - immutable(like say spaceship max speeds, max turn speeds, max HPS etc) - can be stored 1. blob assets 2. components(singletons) - and i believe i read on forum but that was an old thread - in 3. static classes like readonly fields(i think it's possible to use static readonly data from jobs too) - it would be nice to see which method is the most performant especially if this kind of structs that hold the data contains a lot of fields(i bet on 2. but not sure 100%)...
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
Don't know for sure, but I'd say blob assets would be more performant over singleton components because of guaranteed immutability, meaning no safety checks need to happen. Static readonly fields could work but it seems like a bit of a code smell to me as it kinda breaks the ECS model. But great thoughtful comment though!
@mana20
@mana20 2 жыл бұрын
Would you use this for an item system where nothing changes? Or is there a better ECS system for this use case ?
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
Depends on what exactly you are trying to do. So long as the data is unchanging, then yes, a blob asset could be used for something like that. Though often times in games items do have the ability to change over time, maybe they get weaker with use or you can add behavior to them by combining other items. So I could see blob assets being used as a way to store the "base" stats of all the items in your game, then when a player gets an item, those values are copied into something that is mutable like a dynamic buffer. Also I should point out that most people still use OOP for the front-end UI logic of inventory selection/crafting screens as it is easier to do and doesn't really benefit from the performance gains of ECS anyhow. Hope that helps!
@swapnilrane24
@swapnilrane24 2 жыл бұрын
How to build apk file of Dots Project?
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
I'm planning on making some videos soon discussing making builds for DOTS games on different platforms.
@blitzkreig4887
@blitzkreig4887 10 ай бұрын
Is Blob Asset a Scriptable Object for DOTS ? Seems very similar.
@TurboMakesGames
@TurboMakesGames 10 ай бұрын
Kindof! There are a lot of similarities between the two. However just keep in mind that Blob Assets are for static data only
@Tetro48
@Tetro48 2 жыл бұрын
blob assets mentally hurt my brain a bit.
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
They do at first, but once you use them and figure out how best to use them, they begin to make much more sense. It's really just a way to store and reference data that does not change.
Chunks! Where Unity ECS Data is Stored - Unity DOTS 2022
9:27
Turbo Makes Games
Рет қаралды 4,9 М.
How I prepare to meet the brothers Mbappé.. 🙈 @KylianMbappe
00:17
Celine Dept
Рет қаралды 47 МЛН
Маленькая и средняя фанта
00:56
Multi DO Smile Russian
Рет қаралды 4,9 МЛН
100❤️
00:19
Nonomen ノノメン
Рет қаралды 36 МЛН
How to Use Dynamic Buffers in Unity ECS - DOTS Tutorial [ECS Ver. 0.17]
16:28
Data-Oriented Input in Unity ECS - DOTS + Input System 2023
19:24
Turbo Makes Games
Рет қаралды 13 М.
What are BlobAssets ? How to use them ?
8:02
WAYN Games
Рет қаралды 2,5 М.
Unity ECS: Click to Select Units - Unity DOTS Tutorial [ECS Ver. 0.17]
19:40
How I Created 2D Pixel Art Water - Unity Shader Graph
14:11
jess::codes
Рет қаралды 92 М.
When to use Entity Command Buffer in Unity ECS - [Unity DOTS]
11:53
The Hot Path Show Clips
Рет қаралды 1,2 М.
How I prepare to meet the brothers Mbappé.. 🙈 @KylianMbappe
00:17
Celine Dept
Рет қаралды 47 МЛН