Тёмный

Burst your code using ISystem and idomatic foreach in Unity ECS 1.0 

WAYN Games
Подписаться 1,7 тыс.
Просмотров 3,3 тыс.
50% 1

Опубликовано:

 

1 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 22   
@mrbinggrae5954
@mrbinggrae5954 Год назад
I don't know the difference between ISystem and Systembase. . . When should I use Systembase?
@WAYNGames
@WAYNGames Год назад
Hello, The main difference between ISystem and SystemBase is that ISystem can be burst compiled, SystemBase can't. ISytem also don't support the Entities.ForEach syntax, but SystemBase do support the idiomatic foreach syntax. If your game has a lot of systems, the fact that ISystem can be bursted will most likely improve your performance, but threading your code will require more work. On the other hand, if you work on a small game, with few systems, the trival switch between main-thread/single-thread/multi-thread provided by the Entities.ForEach syntax can greatly ease your developpement process. My personnal opinion on the subject is to always use ISystem. I prefer to have a consistent implementation style rather than mixing things up. I started using ECS with it's first experimental release, a few years ago, when we did not have the sugar coating of Entities.ForEach, so I'm used to the additionnal effort required by ISystem to multithread my code. Plus, my understanding is that Entities.ForEach may not be part of 1.0, when it goes out of experimental/preview, since the SourceGenerator it uses are much less performant than the SystemAPI one. glhf in your DOTS projects !
@mrbinggrae5954
@mrbinggrae5954 Год назад
@@WAYNGames Wow!! very thanks
@mrbinggrae5954
@mrbinggrae5954 Год назад
Your video makes me happy. I have to send a long week again. It is sad.
@xinyin9214
@xinyin9214 Год назад
Finally the next video, thank you again!
@mrbinggrae5954
@mrbinggrae5954 Год назад
When are you going to talk about IAspect?
@WAYNGames
@WAYNGames Год назад
That will be for the next video. I'm working the script right now 😁.
@mrbinggrae5954
@mrbinggrae5954 Год назад
@@WAYNGames Very thanks!!!
@madboxtv6853
@madboxtv6853 Год назад
hI thx i see there is a bit more stuff than on CodeMonkey or TurboMakeGame for the 1.0 tutorial. But i see that the baker and baking system are launch on "start" and when they are destroyed ? In my code i tryed to past the code OnCreate but didn't work for the baking Isystem. I just added OnUpdate the state.Enabled = false; I will need to create some flashcard to assimilate this stuff cuz for now it's a totaly new way of programming.
@WAYNGames
@WAYNGames Год назад
Baker and baking system are run in their own world. They only run for authoring the entities in the editor so they are not part of play mode nor are they part of the build. Not sure what your issue is with OnCreate and OnUpdate.
@madboxtv6853
@madboxtv6853 Год назад
@@WAYNGames i suppose i miss something there but baker is not only a editor tool right ? it's the only tool to add component to an entity ? I would like to write in french but will be bad for the other who are like me and trying to understand this paradigme. Aniway i will go further on the topic and i suppose after some time it will make sense
@WAYNGames
@WAYNGames Год назад
Bakers are designed to be editor only. From 1.0 there is no longer any out of the box runtime conversion of game objects to entities.
@proKaps
@proKaps Год назад
IT IS INCREDIBLE! Thank you a lot for your videos, now finally I begin to understand how the ECS works!
@MaxMakesGames
@MaxMakesGames Год назад
Really nice videos man ! Thanks
@lilacsky824
@lilacsky824 Год назад
Very good tutorial.🥰
@MarekNijaki
@MarekNijaki Год назад
Nice video. Question tho: so which approach is better and which one you use the most? To me idiomatic seems little bit more concise so I would probably use it. Also burst is pretty important when it comes to compilations so would also probably use ISystem interface, but it is just a wild guess, that's why I asked my question
@WAYNGames
@WAYNGames Год назад
Thanks for the question. Personally, I will use the ISystem and idiomatic foreach. There is a couple reason for my personal choice. First, I don't want to have two different kinds of syntax in my project. Second, I find that trying to burst as much code as possible lead to two things. Better performance. And better code separation. Since you can't use class with burst you can't just add a reference to whatever across your code base. You must think about what you do and how you do it. That being said, the SystemBase can be inherited which may be useful in some specific situation. Also, DOTS is not full featured yet. If you want to animate or play audio or VFX, you'll have to leave burst and reach back into MB and GO world. Systema Base and Entities.ForEach mays be more convenient in that situation.
@hakanviajando
@hakanviajando Год назад
Hello, thanks for the videos. Are you planning on continuing this series periodically?
@WAYNGames
@WAYNGames Год назад
Hello, yes. I try to keep a one video a week schedule. Next one up will be on IAspect. And I have a good idea of what will be next.
@JohnBowring3D
@JohnBowring3D Год назад
When I use the Entities.ForEach I can get a reference to the Entity itself, when I use the idiomatic foreach in an ISystem, it seems I cannot. Is there any way in an ISystem to get a reference (to store in a quadrant system) to the Entity currently being iterated?
@WAYNGames
@WAYNGames Год назад
foreach ( var (component,entity) in SystemAPI.Query().WithEntityAccess()){}
@JohnBowring3D
@JohnBowring3D Год назад
@@WAYNGames "WithEntityAccess" seems obvious when someone points it out. You sir are a fine gent, thank you.
Далее
Свадьба Раяна Асланбекова ❤️
00:12