Unreal Engine 4.x Scripting with C++ Cookbook - Second Edition
by John P. Doran, William Sherif, Stephen Whittle
Getting ready
In your UE4 code, you're often going to need to refer to different UCLASS in the project. For example, say you need to know the UCLASS of the player object so that you can use SpawnObject in your code on it. Specifying a UCLASS from C++ code is extremely awkward, because the C++ code is not supposed to know about the concrete instances of the derived UCLASS that were created in the blueprints editor at all. Just as we don't want to bake specific asset names into the C++ code, we don't want to hardcode derived blueprints class names into the C++ code.
So, we use a C++ variable (for example, UClassOfPlayer), and select that from a blueprints dialog in the UE4 editor. You can do so using a TSubclassOf member or an FStringClassReference ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access