Search Unity

ECS Deep Dive blog post

Discussion in 'Entity Component System' started by ozirus, Jan 9, 2019.

  1. ozirus

    ozirus

    Joined:
    Apr 2, 2015
    Posts:
    7
    KarelA, asdzxcv777, Flurgle and 13 others like this.
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,770
    This was pleasure to read.



    Really nice content.
    Definitely good article for anyone who starts journey with ECS.

    Not sure if is critical in this state, but I miss mentioning about Injections. Yes they are on the way go away.
    But maybe omitted for a reason, while targeting future ECS evolution?
     
    ozirus likes this.
  3. ozirus

    ozirus

    Joined:
    Apr 2, 2015
    Posts:
    7
    Thank you for the kind words.

    Indeed, Fabrice informed me they were on their way out so I removed their mention ;)
     
    Antypodish and hippocoder like this.
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Hi ozirus, thank you for the generous contribution :)
     
    ozirus likes this.
  5. Fido789

    Fido789

    Joined:
    Feb 26, 2013
    Posts:
    343
    This is a great article, it explains everything very well. It should be the first article people read about ECS. Thank you!
     
    ozirus and Antypodish like this.
  6. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,759
    Great article. My only complaints is the use of GetComponentDataArray and a quick example of chunk iteration and/or IJobChunk would have been great (though you do link to it!)

    Again though, great article.
     
    Last edited: Jan 10, 2019
    ozirus likes this.
  7. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,770
    May I ask, what is wrong with GetComponentDataArray in the article?
    I assume is the lack of example to the job? Or perhaps something different?
     
  8. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,759
    Because, at least the last I heard, it's being removed.
     
  9. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
    Interesting. What is the replacement/alternative to GetComponentDataArray?
     
  10. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,759
    Use IJobProcessComponentData and chunk iteration (IJobChunk).

    https://forum.unity.com/threads/api-usability.550450/#post-3679534

     
  11. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,770
    Uh I just get scared and quickly checked, but I realized, I use GetComponentDataFromEntity. Hence my confusion since they looks similar. I understand from the attached post, GetComponentDataFromEntity is not to be removed?
     
  12. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,759
    GetComponentDataFromEntity is fine. It is quite different.
     
    Antypodish likes this.
  13. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
  14. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,759
    Yeah, needs to be done every on update because the chunks becomes dirty anytime a chunk is changed.

    I find the documentation you linked actually quite confusing, it makes it more complicated than it should be.
    It also doesn't even reference IJobChunk.

    Maybe I'll write a small example for people tomorrow.
     
    ozirus and Mr-Mechanical like this.
  15. ozirus

    ozirus

    Joined:
    Apr 2, 2015
    Posts:
    7
    Thank you for this nice feedback. I'll update the post a bit later today.
     
  16. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
    I agree that any additional info on IJobChunk/chunk iteration would be extraordinarily useful especially since GetComponentDataArray is apparently on its way out.
     
    ozirus likes this.
  17. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,759
    I wrote a little article where I basically wrote the same logic three different ways
    • Iterating chunks in ComponentSystem
    • Using IJobChunk
    • Using IJobProcessComponentData
    I'm not much of a writer and this is the first thing I've ever written so not sure how much use it will be to people. I personally learn a lot better reading source code and so I put an emphasis on that over the actual writing.

    Anyway maybe someone will find it useful, https://www.bovinelabs.com/ecs-hello-world/
     
    c0ffeeartc, ozirus, NotaNaN and 6 others like this.
  18. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,770
  19. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,759
    Way ahead of you, it's already there lol
     
  20. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,770
    Oh lol, I must be really short sighted ;)
     
  21. KarelA

    KarelA

    Joined:
    Dec 30, 2008
    Posts:
    422
    Hi. Thank you for that fantastic blog post.

    Question. Is the presentation made by Fabrice Lété online somewhere? According to slides the talk was called "UniteLA 2018 - ECS deep dive" but i have been not been able to find it anywhere.
     
  22. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,770
    If you got each day LA 2018 schedule, you may be able to find, on one of 1-3 days. Check playlist.
     
  23. KarelA

    KarelA

    Joined:
    Dec 30, 2008
    Posts:
    422
    Thanks. I checked and still no result. The only talk listed by him was ECS Track: Streaming and Serialization one.

    Really strange mystery :) Oh well at least the blog covers it pretty well.
     
    Antypodish likes this.
  24. Vacummus

    Vacummus

    Joined:
    Dec 18, 2013
    Posts:
    191
    You are a better writer then you think. Love how simple and to the point the article is. And you show the entire example and explain a lot of it through comments, which is great. Most article show tidbits of the code and endlessly talk about it which is really annoying.
     
    Mr-Mechanical and Antypodish like this.
  25. ozirus

    ozirus

    Joined:
    Apr 2, 2015
    Posts:
    7
    I think it was presented during a private (non recorded) session.
     
  26. ozirus

    ozirus

    Joined:
    Apr 2, 2015
    Posts:
    7
    Thanks for the very nice blog post @tertle. I updated mine according to your remarks and added a link to your article for a more complete reference.
     
  27. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    @ozirus
    • This is a very nice write up and I hope it gets added to the Unity Documentation Thread that is tagged (@Joachim_Ante)
    • A great addition to your article would be (1) a deep dive into jobs in a similar fashion, (2) a deep dive into native containers
    A lot of info is already out there from the power users like @tertle, @5argon & @eizenhorn who share generously - but you summarized the ECS part very nicely. I would point anyone new to ECS to your Introduction.

    Great contribution!
     
    ozirus and Fishing_Cactus like this.
  28. glad

    glad

    Joined:
    May 10, 2014
    Posts:
    76
    Hi!

    Great article! Thank you!

    You wrote:
    I highlighted in bold the thing I am interested in. I am not sure what you meant by that. Did you mean that one Entity which, lets say, has 10 data fields(structs) could be split into, lets say, 2 chunks: the first one strores first 5 fields, and the second one the other 5 fields?

    Thank you in advance.
     
  29. ozirus

    ozirus

    Joined:
    Apr 2, 2015
    Posts:
    7
    Thanks for the feedback!

    I guess I'll have to rephrase this if it's not clear.

    An entity is never split across multiple chunks. If an entity is composed of 10 components, each chunk of its archetype will contain 10 arrays, 1 per component type. Depending on the number of components in the archetype, a chunk will thus be able to store more or less entities.

    Does it make more sense? If yes, I'll update the article accordingly.
     
  30. glad

    glad

    Joined:
    May 10, 2014
    Posts:
    76
    Oh.. Yes. Now it is clear.

    Thank you!