IndexOutOfRangeException when using IBufferElementData and GenerateAuthoringComponent

Hi! I have a data component that looks like this

[InternalBufferCapacity(32)]
[GenerateAuthoringComponent]
public struct MyBuffer : IBufferElementData {
    public int value;
}

When I add this to a gameobject, which also has a “Convert to entity”-component, the exception listed at the bottom of this post will be thrown as soon as I hit the play button. However, if I increase the size property of the list in the inspector to at least 1, no error will be thrown. Why does this happen? I want the buffer to be empty when I start using it.

Cheers / Fredrik

IndexOutOfRangeException: Index was outside the bounds of the array.
Unity.Entities.Hybrid.BufferElementAuthoring2[TBufferElementData,TWrappedValue].Convert (Unity.Entities.Entity entity, Unity.Entities.EntityManager destinationManager, GameObjectConversionSystem _) (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities.Hybrid/BufferElementDataAuthoringComponent.cs:22) Unity.Entities.Conversion.ConvertGameObjectToEntitySystem.Convert (UnityEngine.Transform transform, System.Collections.Generic.List1[T] convertibles) (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities.Hybrid/GameObjectConversion/ConvertGameObjectToEntitySystem.cs:43)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
Unity.Entities.Conversion.JournalingUnityLogger:LogException(Exception, Object) (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities.Hybrid/GameObjectConversion/JournalingUnityLogger.cs:50)
UnityEngine.Debug:LogException(Exception, Object)
Unity.Debug:LogException(Exception, Object) (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities/Stubs/Unity/Debug.cs:29)
Unity.Entities.Conversion.ConvertGameObjectToEntitySystem:Convert(Transform, List1) (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities.Hybrid/GameObjectConversion/ConvertGameObjectToEntitySystem.cs:48) Unity.Entities.Conversion.<>c__DisplayClass1_0:<OnUpdate>b__0(Transform) (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities.Hybrid/GameObjectConversion/ConvertGameObjectToEntitySystem.cs:56) Unity.Entities.EntityQueryBuilder:ForEach(F_C1) (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities/EntityQueryBuilder_ForEach.gen.cs:230)
Unity.Entities.Conversion.ConvertGameObjectToEntitySystem:OnUpdate() (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities.Hybrid/GameObjectConversion/ConvertGameObjectToEntitySystem.cs:56)
Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities/ComponentSystem.cs:107)
Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities/ComponentSystemGroup.cs:513)
Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities/ComponentSystemGroup.cs:461)
Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities/ComponentSystem.cs:107)
Unity.Entities.GameObjectConversionUtility:Convert(World) (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities.Hybrid/GameObjectConversion/GameObjectConversionUtility.cs:146)
Unity.Entities.ConvertToEntitySystem:Convert() (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities.Hybrid/ConvertToEntity.cs:178)
Unity.Entities.ConvertToEntitySystem:OnUpdate() (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities.Hybrid/ConvertToEntity.cs:67)
Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities/ComponentSystem.cs:107)
Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities/ComponentSystemGroup.cs:513)
Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities/ComponentSystemGroup.cs:461)
Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities/ComponentSystem.cs:107)
Unity.Entities.DummyDelegateWrapper:TriggerUpdate() (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities/ScriptBehaviourUpdateOrder.cs:333)

Can you file a bug report for this, please? Thank you! :slight_smile:

@s_schoener That I will! I wasn’t sure if it was me not understanding something…