Unreal Engine C++ developer.
- I like creating various engine tools that simplify the development process.
- Feel free to email me at [email protected] or join telegram/discord chats for any questions.
Unreal Engine C++ developer.
There is a std::variant class template in the standard library that is essentially a type-safe union. It is generally used when we are not sure in advance which object should be populated from our list of object types, so we assume that one of the specified objects must be there at a time. Unreal Engine has an alternative implementation called TVariant that works the same, except that all the types in the declaring template parameter pack must be unique....
Unreal Engine has an alternative implementation of std::mutex called FCriticalSection which makes it possible for your data to be safely accessed from different threads. This takes the same approach, handling it with one thread locking until the other thread completes the necessary operations. There are two ways to handle lock/unlock logic. The first is low-level, which is used to directly lock and unlock threads. Use with caution due to possible deadlocks ....
This short article addresses the question of how to work with UObjects in a thread-safe way when passing them to some workers, asynchronous tasks, thread pools, or whatever else using a non-game thread. One of the most important issues here is garbage collection. When we pass a UObject* that is not set to root directly to a background thread, it is possible that the passed UObject may be silently deleted by the garbage collector....
By default, when a non-const reference is specified in a function, it will be treated by Blueprints as an output parameter: Show/hide content UFUNCTION(BlueprintCallable) static void RemoveDots(FString& String) { String.ReplaceInline(TEXT("."), TEXT(" ")); } There is a macro called UPARAM which is not widely used, but can control the behavior of parameters specified in UFUNCTIONs. In particular, it can change the behavior of passing non-const references by specifying a ref meta:...
Unreal Engine has a nice feature called AsyncTask, which is used to execute a code asynchronously. It works by running certain code on a specified thread, and this functionality is mostly used when the task is heavy enough to be executed instantly without blocking the game thread. It also provides a solution to all issues arising from multithreading, in particular, accessing parameters from one thread that are supposed to be used and/or edited in another thread....