You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Oh wow, I didn't even know that worked before. But it makes sense, as the Inspectable impl was just a function with self being MyAbility, and the options were created on every ui call.
In the new version InspectorOptions is just a struct that is stored once in the TypeRegistry associated to MyAbility, so it cannot depend on a particular instance.
This could maybe be made to work by not storing NumberOptions for current_charges but instead Fn(&MyAbility) -> NumberOptions that will be evaluated when walking the Reflect to display it, but that would be complicated.
An alternative solution would be to have something like this
#[derive(Reflect,InspectorOptions)#[inspector(validate = |ability| ability.current_charges <= ability.max_charges)]structMyAbility{#[inspector(min = 0, max = 10)]max_charges:u8,#[inspector(min = 0, max = self.max_charges)]current_charges:u8,}
which would only allow changes that pass the validate function.
This would be more flexible and useful for e.g. the Msaa type:
Definitely a nice QOL to have but not critical, mostly for making sure you don't create invalid state like with Msaa, I like the closure idea personally.
For example:
In the previous version this worked fine.
The text was updated successfully, but these errors were encountered: