Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

ECS Deep Dive blog post

Discussion in 'Entity Component System and C# Job system' started by ozirus, Jan 9, 2019.

  1. ozirus

    ozirus

    Joined:
    Apr 2, 2015
    Posts:
    6
    Flurgle, florianhanke, glad and 11 others like this.
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    3,185
    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:
    6
    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 Moderator

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

    Fido789

    Joined:
    Feb 26, 2013
    Posts:
    327
    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:
    910
    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:
    3,185
    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:
    910
    Because, at least the last I heard, it's being removed.
     
  9. Mr-Mechanical

    Mr-Mechanical

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

    tertle

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

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

     
  11. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    3,185
    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:
    910
    GetComponentDataFromEntity is fine. It is quite different.
     
    Antypodish likes this.
  13. Mr-Mechanical

    Mr-Mechanical

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

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    910
    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:
    6
    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:
    125
    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:
    910
    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, GliderGuy and 6 others like this.
  18. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    3,185
  19. tertle

    tertle

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

    Antypodish

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

    KarelA

    Joined:
    Dec 30, 2008
    Posts:
    411
    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:
    3,185
    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:
    411
    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:
    74
    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:
    6
    I think it was presented during a private (non recorded) session.
     
  26. ozirus

    ozirus

    Joined:
    Apr 2, 2015
    Posts:
    6
    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:
    655
    @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:
    50
    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:
    6
    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:
    50
    Oh.. Yes. Now it is clear.

    Thank you!