Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Render non-entity tiles inside Entities.ForEach()

Discussion in 'Graphics for ECS' started by nanaktaev, Sep 19, 2022.

  1. nanaktaev

    nanaktaev

    Joined:
    May 21, 2022
    Posts:
    10
    In my DOTS project there is a top down map (made of cells) and there are creatures.
    Creatures are regular entities and entire map is a kind of huge single entity (with DynamicBuffer<Cell>).
    Several systems will work with that map entity (f.e. FireSpreadSystem, VegetationGrowthSystem and so on).

    My question is: How can I render my DynamicBuffer<Cell> map inside a job (currently I use SystemBase.OnUpdate() with Entities.ForEach())?
    Since my map Cells are not entities I need to render them by myself somehow.
    1. I want to use single material (spritesheet with black backround and white glyphs on it).
    2. All Cells will be square.
    3. I need an access to vertex attributes of Cell mesh in order to send to shader two colors (one for glyph color and another for background color - like in Dwarf Fortress).

    But currently I am unable even to figure out how to acess my material inside ForEach, please help! :)
    I attach an example with desired result: df_example.png
     
  2. nanaktaev

    nanaktaev

    Joined:
    May 21, 2022
    Posts:
    10
    I have learned now that I can access my Material inside ForEach if I use it WithoutBurst() and Run().
    But as far as I understand this is single thread solution. It's interesting how to do it with ScheduleParallel().
     
  3. nanaktaev

    nanaktaev

    Joined:
    May 21, 2022
    Posts:
    10
    I was dumb. Where is no reason to make it ScheduleParallel() since it always processes only one Map comonent always!