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

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:

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

8171594–1063490–error.txt (59.5 KB)
8171594–1063496–Player.txt (37.6 KB)

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?

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)’

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

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:

        float3 scale = new float3(widthScale, widthScale, heightScale);
        _entityManager.AddComponent<NonUniformScale>(_prefabEntities[entityIndex]);
        try
        {
            _entityManager.SetComponentData(instance, new NonUniformScale { Value = scale });
        }
        catch
        {
            Debug.Log("couldn't set scale");
        }

This caused builds with prefabs to crash. I switched my code to this and it now works fine:

        float3 scale = new float3(widthScale, widthScale, heightScale);
        _entityManager.AddComponentData<NonUniformScale>(_prefabEntities[entityIndex], new NonUniformScale { Value = scale });
1 Like