jakobhellermann / bevy-inspector-egui

Inspector plugin for the bevy game engine
Apache License 2.0
1.18k stars 173 forks source link

Add reflected Map controls #155

Closed B-Reif closed 11 months ago

B-Reif commented 12 months ago

This PR adds support for editing reflected Map values. Specifically:

image image

It should be noted the 'add element' draft implementation is pretty inefficient. It uses egui's IdTypeMap which internally clones the element, and also clones the element itself to move the value out of state for use. If we have a better way to store this (on the InspectorUi struct? in the Bevy world?) that would be an improvement.

jakobhellermann commented 11 months ago

Very nice, thanks you!

It should be noted the 'add element' draft implementation is pretty inefficient. It uses egui's IdTypeMap which internally clones the element, and also clones the element itself to move the value out of state for use. If we have a better way to store this (on the InspectorUi struct? in the Bevy world?) that would be an improvement.

I think for an a feature like this it doesn't matter too much if this does some unnecessary clones. When it becomes obviously slow we can reconsider.