Error - IBufferElementData and GenerateAuthoringComponent

When I apply the GenerateAuthoringComponent attribute to an IBufferElementData with a single field, it shows up in the Inspector as a Component with an array of single “Element” values:

[GenerateAuthoringComponent]
public struct FooBufferElementData : IBufferElementData
{
    public float bar;
}

I’m not sure what’s going on here. What do the “Element” items represent here?

If I add a second field to the IBufferElementData struct…

[GenerateAuthoringComponent]
public struct FooBufferElementData : IBufferElementData
{
    public float bar;
    public int baz;
}

…I get this console error:

There’s clearly an intention behind the design here, but it’s unintuitive atm. It feels like maybe Unity added auto-gen support for IBufferElementDatas recently, but only for a very specific use case, which may not be documented yet. Or, I missed the documentation/release notes.

Can anyone explain what’s happening? Thank you for any help.

2 Likes

Looks like there’s useful information about this in

However, still no explanation for why it’s implemented this way.

1 Like