Hey all, I wanted to raise awareness of a fix for the issue that has been around for a while in SubScene imports running on the background Unity process. This usually manifests with this error:
[Worker0] Exception thrown during SubScene import: System.InvalidCastException: Specified cast is not valid.
And sometimes you see it as this:
[Error] Loading Entity Scene failed because the entity header file couldn’t be resolved.
The second error is just a general report that the SubScene failed to import and thus couldn’t be loaded. The real error is what is happening on the worker with the invalid cast.
This issue has finally been figured out, and turns out to have been a bug in Mono itself. This means there won’t be a patch for the Entities package, as we ship Mono embedded in Unity and so the fix has gone into the following Unity releases:
2022.3.57f1
6000.0.35f1
6000.1.0b3
So please update to these Editor versions if you’re running into this problem.
I apologise for how long it took to get to the bottom of this, I know it has been a source of frustration to work with Entities projects and SubScenes because of this. Believe me when I say we’ve been dealing with the same pain internally as well, it was just a particularly hard bug to pin down. But it finally is, thanks to some real hard work by a few colleagues!
Please let us know here if you find this problem again after updating your Editor versions to the above (or newer).