This chapter focuses on how to create C++ classes and structs that integrate well with the UE4 blueprints editor.
The classes we will be creating in this chapter are graduated versions of the regular C++ classes, and are called UCLASS.
Using UCLASS is a great practice to get into. The UCLASS macro, if configured correctly, can possibly make your UCLASS blueprintable, which can enable your custom C++ objects to be used within Unreal's visual-scripting language blueprints. This can be really useful if you have designers on your team, as they can access and tweak aspects of your project without having to dive into code.
We can have blueprint's visually editable properties (UPROPERTY) with handy UI widgets such as text fields, sliders, and model selection boxes. You can also have functions (such as UFUNCTION) that are callable from within a blueprints diagram. Both of these are shown in the following screenshots:
On the left, two UPROPERTY decorated class members (a UTexture reference and an FColor) show up for editing in a C++ class's blueprint. On the right, a C++ GetName function marked as BlueprintCallable UFUNCTION shows up as callable from a blueprints diagram.
UE4 code is, typically, very easy to write and manage once you know the patterns. The code we write to derive from another UCLASS, or to create a UPROPERTY or UFUNCTION instance, is very consistent. This chapter provides recipes for common UE4 coding tasks revolving around basic UCLASS derivation, property and reference declaration, construction, destruction, and general functionality.