Search Unity

Hybrid Renderer crashing in build as soon as I go to instantiate entities

Discussion in 'Graphics for ECS' started by conlanstewart, Jun 1, 2022.

  1. conlanstewart

    conlanstewart

    Joined:
    Mar 2, 2022
    Posts:
    12
    I have had this really strange issue pop up using the hybrid renderer, and I can't seem to figure out where to look next for solutions. Currently, here's what I'm trying to do:

    1.) Get data for entities and gameobjects I'll be placing from a file
    2.) Go through my list of prefabs and create entities from them
    3.) Instantiate them, scale them, and place them at a position

    This works great in editor, but crashes in a build after I instantiate them. This was working in the past, has just recently stopped working in builds.

    I tried the solution in this thread, but didn't have any luck, it just crashed every time I tried to launch it:
    https://forum.unity.com/threads/hyb...rashes-player-but-works-in-play-mode.1047041/

    My unity version is 2020.3.7f1 using Entities 0.17 and HybridRenderer 0.11 and Jobs 0.8 and my scripting background is set to Mono. I'll attach my log files, and please let me know if I'm leaving out any critical info and I'll reply as soon as I get to my desk in the morning

    Thanks so much for your time
     

    Attached Files:

  2. joelv

    joelv

    Unity Technologies

    Joined:
    Mar 20, 2015
    Posts:
    203
    It looks like a crash in hybrid renderer or entities for sure. Would it be possible for you to test with a newer version of the packages? Or report a bug with a repro case so that we can try to repro it ourselves using the newer versions?
     
  3. conlanstewart

    conlanstewart

    Joined:
    Mar 2, 2022
    Posts:
    12
    When trying to update the hybrid renderer, I get a bunch of errors with the entities package, but I can't update the entities any further than 0.50.1, do I need a different version of Unity to use a newer version of Entities?

    The errors read out like:
    Library\PackageCache\com.unity.entities@0.50.1-preview.2\Unity.Entities.Editor\Unity.InternalAPIEditorBridge.002\ProfilerModules\StructuralChangesProfilerModuleBridge.cs(5,23): error CS0234: The type or namespace name 'Editor' does not exist in the namespace 'Unity.Profiling' (are you missing an assembly reference?)

    And:
    Library\PackageCache\com.unity.entities@0.50.1-preview.2\Unity.Entities.Editor\Unity.InternalAPIEditorBridge.002\ProfilerModules\StructuralChangesProfilerModuleBridge.cs(14,11): error CS0534: 'StructuralChangesProfilerModuleBridge' does not implement inherited abstract member 'ProfilerModuleBase.DrawToolbar(Rect)'
     
    Last edited: Jun 1, 2022
  4. conlanstewart

    conlanstewart

    Joined:
    Mar 2, 2022
    Posts:
    12
    Ok, I fixed the above error by updating to Unity 2020.3.35f1, and now my entities is at .50.1 and hybrid renderer is at .50.0, and I'm still getting the same error. While I was looking for what else could be wrong, I came across somebody that had a similar error and he had a corrupt prefab/model he was trying to create an entity out of. I did recently update the models, so I'm wondering how I could check each model for issues? Again, this is all working in editor, but still crashes in a build when going to place the entities
     
  5. conlanstewart

    conlanstewart

    Joined:
    Mar 2, 2022
    Posts:
    12
    Finally figured this out, figured I'd explain in case anybody has similar issues, or if anybody has any idea why this ended up being the solution an explanation would be awesome.

    The original assets I was using were .fbx models, and for some reason switching to prefabs caused a crash in build, but worked in editor. Like I said in the initial post, I was scaling them, which ended up being the problem. For some reason, the logic I was using:

    Code (CSharp):
    1.         float3 scale = new float3(widthScale, widthScale, heightScale);
    2.         _entityManager.AddComponent<NonUniformScale>(_prefabEntities[entityIndex]);
    3.         try
    4.         {
    5.             _entityManager.SetComponentData(instance, new NonUniformScale { Value = scale });
    6.         }
    7.         catch
    8.         {
    9.             Debug.Log("couldn't set scale");
    10.         }
    This caused builds with prefabs to crash. I switched my code to this and it now works fine:

    Code (CSharp):
    1.         float3 scale = new float3(widthScale, widthScale, heightScale);
    2.         _entityManager.AddComponentData<NonUniformScale>(_prefabEntities[entityIndex], new NonUniformScale { Value = scale });
     
    joelv likes this.