Daily Unreal Column #88 - FScopedBusyCursor
Have you ever thought about how to provide a user feedback when making a tools that take more than a fraction of a second to run? Unreal got you covered with some nice structures built in.
One of the goodies that is available to use is FScopedBusyCursor. This structure is extremely simple to use and understand. What it does is, within the scope a variable of this type is created, it changes the operating system default cursor to a “busy” cursor. Busy cursor in Windows 10 is the spinning circle I’m sure most of you’ve seen.
As soon as the variable runs out of the scope (at the end of the function at latest unless you explicitly declared the variable on a heap) the cursor is being changed back to normal. Let’s have a look at an example code using it.
void AMyActor::Foo()
{
...
...
...
{
// Creating busy curosr, default cursor is being
// replaced with busy cursor here.
FScopedBusyCursor BusyCursor;
for (int32 Index = 0; Index < VeryBigNumber; Index++)
{
...
...
...
}
}
// Busy cursor doesn't exist here so normal cursor is
// being set here.
}
Subscribe to Robert Lewicki
Launched 10 months ago
Daily Unreal Column is a project about sending one and only one bite-sized news per day at 12pm CET, from Monday to Friday, to expose you to a features of Unreal Engine that are not very well known.