bevy
bevy copied to clipboard
Make arrays behave like lists in reflection
Objective
Currently, arrays cannot indexed using the reflection path API.
This change makes them behave like lists so x.get_path("list[0]") will behave the same way, whether x.list is a "List" (e.g. a Vec) or an array.
Solution
When syntax is encounterd [ <idx> ] we check if the referenced type is either a ReflectRef::List or ReflectRef::Array (or ReflectMut for the mutable case). Since both provide the identical API for accessing entries, we do the same for both, although it requires code duplication as far as I can tell.
This was born from working on #5764, but since this seems to be an easier fix (and I am not sure if I can actually solve #5812) I figured it might be worth to split this out.