DefaultGameObjectInjectionWorld is always NULL in 0.14.0-preview.18

Unity.Entities.World.DefaultGameObjectInjectionWorld is always NULL after upgrading the entities package to the latest version. Unity is at 2020.1.2f1.

After restarting Unity, it is no longer always NULL, but maybe 1 out of every 10 times I hit Play, it will end up being null.

I think there’s a data race somewhere in the ECS init code.

At what time are you trying to access it?

A quick look at code and the initialization looks pretty unchanged to me, though I haven’t diffed it

it’s basically set straight away

var world = new World(defaultWorldName, editorWorld ? WorldFlags.Editor : WorldFlags.Game);
World.DefaultGameObjectInjectionWorld = world;

being called from

[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]

It was null even later, in Update functions. Weirdly enough, the problem went away by itself after another Editor restart. Shrug emoji?