Display Bufferelement data in entities hierarchy inspector

Hi,
I am using Unity 2022.20f1, ECS, Physics, graphics 1.0.0-pre15.

When running you can see the actual values of the components of the entities in the entity hierarchy.
Question is about the showing of data within a DynamicBuffer<>.

I have a route element :

public struct RouteElement : IBufferElementData
{
    public float3 elementPosition;
}

When using this in Buffer I see this in the inspector :
8658396--1165782--RouteBuffer.PNG

It is showing the elements, including the data.

I am also using the statefull triggers from the Physics examples

There is the bufferelement

    public struct StatefulTriggerEvent : IBufferElementData, IStatefulSimulationEvent<StatefulTriggerEvent>
    {
        public Entity EntityA { get; set; }
        public Entity EntityB { get; set; }
        public int BodyIndexA { get; set; }
        public int BodyIndexB { get; set; }
        public ColliderKey ColliderKeyA { get; set; }
        public ColliderKey ColliderKeyB { get; set; }
        public StatefulEventState State { get; set; }
        public StatefulTriggerEvent(TriggerEvent triggerEvent)
        {
            EntityA = triggerEvent.EntityA;
            EntityB = triggerEvent.EntityB;
            BodyIndexA = triggerEvent.BodyIndexA;
            BodyIndexB = triggerEvent.BodyIndexB;
            ColliderKeyA = triggerEvent.ColliderKeyA;
            ColliderKeyB = triggerEvent.ColliderKeyB;
            State = default;
        }
        // Returns other entity in EntityPair, if provided with one
        public Entity GetOtherEntity(Entity entity)
        {
            Assert.IsTrue((entity == EntityA) || (entity == EntityB));
            return (entity == EntityA) ? EntityB : EntityA;
        }
        public int CompareTo(StatefulTriggerEvent other) => ISimulationEventUtilities.CompareEvents(this, other);
    }

For that I get this :

8658396--1165785--Stateful.PNG

It is only showing the number of elements, not the actual content.

Presume I have to add additional (editor?/inspector?)code to get that done.
Can someone point me to the documentation on how to achieve that ?

Adding this line for each property should do the trick:

[field: SerializeField]

Unity doesn’t serialize the backing fields of auto properties by default. This line tells Unity to do so.

1 Like

Thanks,

It worked, much easier than I expected.