After reviewing the documentation for the CallbackProperty I was curious about what happens internally when the isConstant flag is set to true? The docs say "when the callback function returns the same value every time, false if the value will change."
Is this the same as swapping out the CallbackProperty with a static property so that there is not a performance penalty for it getting called constantly?
Let's say I have a shape drawing function that adds UI through the CallbackProperty, would it be better to set this property to True when finished and no more changes will happen or should I still set it back to a constant?
I believe if isConstant is true, the function only gets called once, at the time the entity is created because it is assumed the function will always return the same value. If it is false, we assume the return value of the function changes so the function will be called every frame to get the new value.
I’m not sure which method would be better, but if you do want to try changing the value of isConstant, use the CallbackProperty.setCallback property.
Thanks for the confirmation. It would be nice to be able to just flip the bool value of isConstant when moving to editing mode and back instead of swapping with a static property each time. I will give this a try to see if it works.
This will definitely work (assuming isConstant isn’t readonly). It would be trivial to expose this capability.
The performance characteristics will be the same in both cases, but setting the boolean to try definitely sounds cleaner to me and I would recommend this approach going forward.