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

Bug Empty IBufferElementData crashes Unity Editor

Discussion in 'Entity Component System' started by jennal, Dec 14, 2022.

  1. jennal

    jennal

    Joined:
    Oct 28, 2017
    Posts:
    24
    If you define something like this:
    Code (CSharp):
    1. public struct Foo : IBufferElementData
    2. {
    3. }
    Unity Editor crashes, and crashes every time when you reopen this project with Unity Edtior. After remove this code, editor can open without crash.
     
  2. PolarTron

    PolarTron

    Joined:
    Jun 21, 2013
    Posts:
    87
    Interesting. Might have to do with the way it's trying to calculate how many elements fit inside 128 bytes. When the size is zero, infinite?

    What happens if you add [InternalBufferCapacity(8)] to the struct?
     
  3. runner78

    runner78

    Joined:
    Mar 14, 2015
    Posts:
    760
    I was wondering what is the use case for empty buffer elements?
     
  4. PolarTron

    PolarTron

    Joined:
    Jun 21, 2013
    Posts:
    87
    The pragmatic side of my brain was turned off when I made the above reply. I'm wondering the same thing now.
    Indeed. Why not use a regular component with a counter?

    But a warning should be printed either way and not crash.
     
  5. jennal

    jennal

    Joined:
    Oct 28, 2017
    Posts:
    24
    Maybe it is my coding habit..I know I need a buffer element type, but I don't know what content should it have for now. And I will fill its content later. But when I save the empty buffer element, Unity Editor will automatically compile and crash.