Unity Job System — A Practical Code Example

preview_player
Показать описание

In this video, we'll use the Unity Job System to optimize some CPU-intensive code.

#Unity3D #GameDevelopment

Unity's Data-Oriented Technology Stack — Unity DOTS for short — is a package that consists of the Unity Job System, Entity Component System, and Burst Compiler. When used together, these tools add multithreading and an optimized memory layout to your project by default. But it also locks your Unity project into a framework that both requires a mindset shift and is hard to change later. So in this Unity Tutorial, we'll see if we can use just the Unity Job System to optimize some CPU-intensive code.

My Favorite Unity Assets 💯⤵️

* Disclosure: These are affiliate links, which means I'll receive a commission if you use them to make a purchase.
Рекомендации по теме
Комментарии
Автор

Great stuff. I need to watch this a few times but i can see a future where i can master this now - and yes, more on the issues that we will bump into is welcome in future videos

happyfarang
Автор

Absolutely stunning tutorial! I'm so grateful there are developers like you that take the time to make such polished tutorials!!

robelso
Автор

Great video! A couple things though, at 7:55 when changing the data in the NativeArray, it's not really right to describe this as a "quirk of the job system". You're changing a value type inside an array, you would need to read the data, change it, and write it back to the array, regardless of whether or not you were inside of a job.

Also typically with this setup you would want to schedule the jobs inside Update then call complete inside LateUpdate, this way your job actually has a chance to run in the background while other things are happening instead of just immediately blocking the main thread until the job completes.

Sarkahn
Автор

you overwhelmed me with the intro and I know what that stuff means.

XZYSquare
Автор

It's great to have a real world usage example.
I haven't tried JobSystem yet, but looks awesome how it's easy to improve the code.

OTadashi
Автор

Nice video - by the way, the job system example video you did back in 2018 I believe was one of the most helpful videos I found to get my started with the job system back then :)

dreamisover
Автор

I tried using full-DOTS on my first ever game. It feels very nice and intuitive at the start ("This object can move straight forward, can rotate on the X-axis"), but if you're getting somewhat further than just a basic level then it starts getting very difficult to know how to proceed.
I scrapped that entirely after about two days and tried a standard approach. I occasionally get that itch though, you know

modernkennnern
Автор

Great explainer! thanks. Clearly you're set to be the best channel in the segment on YT!

Some off-topic questions though, what's your desktop resolution and why do you prefer intelliJ over others (I can already see some reasons)?
And would it be a good idea to use this functionality for certain things on my production ready app for the Android platform?

diplodocus
Автор

12:25 Why did you use TempJob instead of Persistent allocation even though you disposed the array on destroy?

mastermati
Автор

Love your presentation and examples.
Just the right amount of theory and practice.
Keep rocking hard, dude!

ristopaasivirta
Автор

Amasing video, your capacity for explane all simply is hight.
Gracias.

wes
Автор

A part of me is struggling with the fact all of this has to be done with structs, even though it makes sense in the context of what jobs do. The struggle is with how when you make changes to a struct, the entire struct is copied; with structs with a bit more complexity (more properties) this seems like such an inefficient method. Are my concerns valid, or is there something I'm overlooking here? Or is this copying not actually as 'heavy' for the processor?

DutchyChannel
Автор

Should have just had calcution for, number of Tennants * random number. Or randrange(12*tennentsCount, 24*tennetCount).
Could also add some noise by adding randondom int, 1 to tennentCount

ashtwenty
Автор

Thank you so much! Very clear explanation of how these systems work and use in real cases.

zendsub
Автор

what if the number of items to be processed dynamic?

kokizzu
Автор

How dots system fare now in 2021, is it really okay to go to that direction completely??

greendino
Автор

will this way to return data from a job work with any object? I mean if tentants or PowerUsage were something different than an int. I need to return a Texture2d

miguelangelgalindo
Автор

Production quality is really good. Although I wish you'd explain new concepts for dummies.

Sadly you didn't really explain in this tutorial, rather you read out loud what we have to type.
I wasn't able to take away as much, as the concepts you used in the Jobification step weren't explained well.

SnipeIRL
Автор

Can I use this for Tcp connections, instead of c# threads/ tasks ?

peny
Автор

hello, I was going to use job system in my project, but I realized it didn't work. I used the example in your video and saw that the job system was working, but this time, when I deleted the math part you wrote, I saw that it didn't make any difference. So then why did you write the other codes?
Does the job system only work for the math library?

ibrahimAlbayrak