Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

IndexOutOfRangeException when using IBufferElementData and GenerateAuthoringComponent

Discussion in 'Entity Component System' started by astrogee, Oct 24, 2020.

  1. astrogee

    astrogee

    Joined:
    Feb 4, 2018
    Posts:
    16
    Hi! I have a data component that looks like this

    Code (CSharp):
    1. [InternalBufferCapacity(32)]
    2. [GenerateAuthoringComponent]
    3. public struct MyBuffer : IBufferElementData {
    4.     public int value;
    5. }
    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.BufferElementAuthoring`2[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.List`1[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, List`1) (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_C`1) (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)
     
  2. s_schoener

    s_schoener

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    81
    Can you file a bug report for this, please? Thank you! :)
     
  3. astrogee

    astrogee

    Joined:
    Feb 4, 2018
    Posts:
    16
    @s_schoener That I will! I wasn't sure if it was me not understanding something...