Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Bug RenderMeshArray contains lot of nulls in Build

Discussion in 'Graphics for ECS' started by StefanWo, Apr 4, 2023.

  1. StefanWo

    StefanWo

    Joined:
    May 24, 2015
    Posts:
    124
    Not sure what it cause, but most of my RenderMeshArrays contained mesh and materials are null. I debugged a bit, the baker in the build seems adding it correct, but when i debug it they are not there anymore.

    I used subscene conversion to create them. Any idea how this could happen?
     
  2. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    352
    The baking should not place any nulls in RenderMeshArray on purpose. Are you seeing nulls in the editor, or do the nulls only appear in the player?

    Can you file a bug report with a repro project so we can investigate the issue?
     
  3. StefanWo

    StefanWo

    Joined:
    May 24, 2015
    Posts:
    124
    Thanks for the fast response, its only in the build version. After a long try and error session i found the problem. What i did:
    After loading the scene, i removed all scene tags from the entities and removed the scene, so i am in the state where only the entities of the scenes exists. After one frame all mesh and materials are null, i guess they are being destroyed from a cleanup?

    In the Editor this worked perfect, but in the Build it looks like its destroying the Mesh and Materials.

    In Editor: It worked
    With Entities 0.5 where i updated from: It worked
    After build: They are null

    Here the code i used directly after the scenes finished loading:
    Code (CSharp):
    1. EntityManager.RemoveComponent<SceneSection>(new EntityQueryBuilder(Allocator.Temp).WithAll<SceneTag>().WithOptions(EntityQueryOptions.IncludePrefab | EntityQueryOptions.IncludeDisabledEntities).Build(EntityManager));            EntityManager.RemoveComponent<SceneTag>(new EntityQueryBuilder(Allocator.Temp).WithAll<SceneTag>().WithOptions(EntityQueryOptions.IncludePrefab | EntityQueryOptions.IncludeDisabledEntities).Build(EntityManager));
    2. SceneSystem.UnloadScene(EntityManager.World.Unmanaged, sceneEntity, SceneSystem.UnloadParameters.DestroyMetaEntities);
     
  4. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    352
    It's possible that doing that somehow triggers unloading the meshes and materials, since in the player those are also loaded when the subscene is loaded. I would suggest leaving the scene related things as is, unless you are explicitly trying to unload the scene (in which case the entities should also disappear)
     
    StefanWo likes this.