I have recently been wondering if there are any real performance differences between binding a UMG item’s value to a function vs binding it directly to a variable. I know that the function method will run the function every frame, which because of obvious reasons isn’t the most performance efficient. But what about binding it directly to a variable?
The thing is, you would use the function to calculate something. For example the percentage of a progressbar. Like CurrentHealth/MaxHealth.
Even if you bind that progressbar to a variable, you would need to calculate the percentage somewhere.
If you can use only a variable, like just displaying the CurrentHealth, then use a variable, but if you need to calculate something like above, then you might want to
use a functionbinding. You can also check pointers etc in it and change values based on it. Making the Currenthealth to “N/A” when the Character is destroyed or something.
This has already been covered in another thread, https://forums.unrealengine.com/showthread.php?84604-UMG-Slate-Binding-Property-or-Function-Performance-differences
Well, an example of how I might use either of them to do the same thing is if I have a tab, and when I click it I want it to switch to the active tab color, and set it to the inactive tab color when I click out of it. That could be done by using a ‘Current Tab Color’ that is variable-bound, and setting it, or it could be done by using a function, and a select color with a boolean.
I am getting rid of my bindings all together. I am working on a chat system, and each message has the username and message text bound to a variable. With 1000 messages in the chat box, I was getting an FPS of ~28. After removing the bindings and setting the values directly, I was getting ~39 FPS with 1000 messages.
You should definitely never use bindings for static data.