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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Too much time in RenderMeshSystemV2

Discussion in 'Graphics for ECS' started by efpoman, Aug 18, 2020.

  1. efpoman

    efpoman

    Joined:
    Mar 24, 2020
    Posts:
    6
    Hi, im trying to instantiate a bunch of entities and move them at runtime. They are currently instantiated but the RenderMeshSystemV2 takes too long. Captura.PNG
    Someone know how to reduce this time?I leave the code that I use to instantiate here below
    Code (CSharp):
    1.  if (spawnBallsAuto)
    2.         {
    3.             //for (int i = 0; i < 10; i++)
    4.             //{
    5.             objfps = GameObject.FindGameObjectWithTag("FPSCount");
    6.             objfps.GetComponent<BallsCount>().balls += 1;
    7.             //obtenemos los ghost
    8.             var ghostCollection1 = GetSingleton<GhostPrefabCollectionComponent>();
    9.             //obtenemos el id del ghost que nos interesa
    10.             var ghostId1 = ProyectoNetcodeGhostSerializerCollection.FindGhostType<PelotaSnapshotData>();
    11.             //su prefab
    12.             var prefab1 = EntityManager.GetBuffer<GhostPrefabBuffer>(ghostCollection1.serverPrefabs)[ghostId1].Value;
    13.             //y lo instanciamos
    14.             var pelota = EntityManager.Instantiate(prefab1);
    15.             float xa = UnityEngine.Random.Range(-10, 10);
    16.             float ya = 2.5f;
    17.             float za = UnityEngine.Random.Range(-10, 10);
    18.             //le añadimos el componente de posicion
    19.             EntityManager.SetComponentData(pelota, new Unity.Transforms.Translation { Value = new float3(xa, ya, za) });
    20.         }
    And the code to move the entities
    Code (CSharp):
    1. public class MovePelotaSystem : JobComponentSystem
    2. {
    3.     protected override void OnCreate()
    4.     {
    5.         RequireSingletonForUpdate<EnableProyectoNetcodeGhostSendSystemComponent>();
    6.     }
    7.     protected override JobHandle OnUpdate(JobHandle inputDeps)
    8.     {
    9.         return Entities.WithAll<PredictedGhostComponent>().ForEach((ref Translation trans,ref PelotaComponent pelota) =>
    10.         {
    11.  
    12.             if (trans.Value.y >= 9)
    13.                 trans.Value.y = 2.5f;
    14.             else
    15.                 trans.Value.y += 0.03f;
    16.         }).Schedule(inputDeps);
    17.     }
    18. }
    19.  
     
  2. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,986
    Show timeline view in profiler? It could just be waiting for transform systems to complete. The Hybrid Renderer hard completes all JobHandles operating with LocalToWorld.
     
  3. runner78

    runner78

    Joined:
    Mar 14, 2015
    Posts:
    760
    Is a little confusing, but RenderMeshSystemV2 is the older renderer, and HybridRendererSystem is Hybrid Renderer V2. At least in 0.8.0-preview.18. I have with 24,000 cubes with Build-in and RenderMeshSystemV2 40ms, with HybridRendererSystem and URP 9.0 1.5ms.

    You can also try ScheduleParallel.
     
  4. efpoman

    efpoman

    Joined:
    Mar 24, 2020
    Posts:
    6
    Thank you two, i try deactivating my transform systems but still wasting too much time. I've tried to install HybridRendererV2 but it gives me errors for other packages that I can't update right now. Anyway i try with ScheduleParallel and that reduces the time noticeably