Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Adding Graphics with a Baker?

Discussion in 'Graphics for ECS' started by thelebaron, Nov 12, 2022.

  1. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    825
    Theres an api for runtime, and I found a messy workaround to copy a prefab entity's components inside of a baking system but if I want to do some stuff inside of a baker I cant appear to find anything currently that isn't internal to support this. Is this planned in any way?
     
  2. mcfadyeni

    mcfadyeni

    Joined:
    Sep 1, 2022
    Posts:
    3
    Not sure about adding the components itself. The way I've done this so far is to do `GetEntity(gameObject)` on the GameObject that the graphics (Mesh Filter etc) is on, and then spawning that (both inside the baker).

    As far as I can tell, the `GetEntity` does the conversion of the graphics stuff automatically (it converts the components to their Entities Graphics counterparts for you).
     
  3. StefanWo

    StefanWo

    Joined:
    May 24, 2015
    Posts:
    118
    You can just replace the RenderMesh in a BakingSystem, seems working fine for me. To be sure, maybe its good to do it in the
    Code (CSharp):
    1.  
    2. [UpdateInGroup(typeof(TransformBakingSystemGroup))]
    3. ...
    4.             var renderMesh = EntityManager.GetSharedComponentManaged<RenderMesh>(entity);
    5.             renderMesh.mesh = newMesh;
    6.             EntityManager.SetSharedComponentManaged(entity, renderMesh);
    7.