Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException in CreateBuffersContainer after upgrading to Entities 0.17.0-preview.42 #18

Closed
TarasMartynyuk opened this issue May 10, 2021 · 2 comments

Comments

@TarasMartynyuk
Copy link

Trying to launch the SingleSpriteSheetSpawner demo, and getting callstack below. In short, DynamicBufferManager.CreateBuffersContainer crashes when creating this archetype:

var archetype = EntityManager.CreateArchetype(
          typeof(SpriteIndexBuffer),
          typeof(MatrixBuffer),
          typeof(SpriteColorBuffer),
          typeof(SpriteSheetMaterial),
        typeof(UvBuffer)
        );

It works on previous version - 0.16.0-preview.21
Interestingly, creating the same archetype elsewhere - I did it in Convert() of SingleSpriteSheetSpawner - works.

Callstack:

NullReferenceException: Object reference not set to an instance of an object
Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckWriteAndThrow (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) (at <a5172b547855499dbc8d9d50552f0797>:0)
Unity.Entities.EntityManager.GetCheckedEntityDataAccess () (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/EntityManager.cs:76)
Unity.Entities.EntityManager.CreateArchetype (Unity.Entities.ComponentType[] types) (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/EntityManagerCreateArchetype.cs:29)
DynamicBufferManager.CreateBuffersContainer (SpriteSheetMaterial material) (at Assets/SpriteSheetRenderer/Scripts/DynamicBufferManager.cs:58)
DynamicBufferManager.GenerateBuffers (SpriteSheetMaterial material, System.Int32 entityCount) (at Assets/SpriteSheetRenderer/Scripts/DynamicBufferManager.cs:46)
SpriteSheetManager.RecordSpriteSheet (UnityEngine.Sprite[] sprites, System.String spriteSheetName, System.Int32 spriteCount) (at Assets/SpriteSheetRenderer/Scripts/SpriteSheetManager.cs:134)
SingleSpriteSheetSpawner.Convert (Unity.Entities.Entity entity, Unity.Entities.EntityManager eManager, GameObjectConversionSystem conversionSystem) (at Assets/SpriteSheetRenderer/Examples/SingleSpawnSprite[DEMO]/Script/SingleSpriteSheetSpawner.cs:36)
@TarasMartynyuk
Copy link
Author

TarasMartynyuk commented May 10, 2021

The problem was with a Singleton-like EntityManager static variable in DynamicBufferManager (and one more class). It was initialized unless null, but at some point Unity changed EntityManager from class to struct, so the default value of variable was never null, and it was left uninitialized.

@fabriziospadaro
Copy link
Owner

The problem was with a Singleton-like EntityManager static variable in DynamicBufferManager (and one more class). It was initialized unless null, but at some point Unity changed EntityManager from class to struct, so the default value of variable was never null, and it was left uninitialized.

Yeah, this was 100% correct.
I just fix this along with other problems while upgrading to the latest unity version and entitas v0.17.0-preview.42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants