[Solved] Issue with Length injection for Entities package 12-preview.8

After upgrading entities to 12-preview.8 I’m getting an error saying that “Length” has to be initialized with the readonly attribute even though I’ve already marked it as ReadOnly.

Going through the code it seems that there’s a bug on Unity.Entities.InjectComponentGroup.cs #221:

As the injection is done in via a struct, the Length cannot be initialized upfront, thus line 225 will never be called.

Below are some screenshots of the issue:

3553433--285904--upload_2018-7-5_2-33-3.png

Is it only me or does anyone else face the same problem?

Right now the workaround is getting the length from one of the injected arrays.

Attribute “ReadOnly” is not a keyword “readonly”. I post about this here Preview 8.

2 Likes

Yeah that fixed the issue. Thanks.

3553437--285905--upload_2018-7-5_2-56-19.png