Blueprinting is just the process of deriving a Blueprint class for your C++ object. Creating Blueprint-derived classes from your UE4 objects allows you to edit the custom UPROPERTY
visually inside the editor. This avoids hardcoding any resources into your C++ code. In addition, in order for your C++ class to be placeable within the level, it must be Blueprinted first. But this is only possible if the C++ class underlying the Blueprint is an Actor
class-derivative.
There is a way to load resources (such as textures) using FStringAssetReferences
and StaticLoadObject
. These pathways to loading resources (by hardcoding path strings into your C++ code) are generally discouraged, however. Providing an editable value in a UPROPERTY()
, and loading from a proper concretely typed asset reference is a much better practice.
You need to have a constructed UCLASS
that you'd like to derive a Blueprint class from (see the Making a UCLASS – deriving from UObject section earlier in this chapter) in order to follow this recipe. You must have also marked your UCLASS
as Blueprintable
in the UCLASS
macro for Blueprinting to be possible inside the engine.
UserProfile
class, first ensure that UCLASS
has the Blueprintable
tag in the UCLASS
macro. This should look as follows:UCLASS( Blueprintable ) class CHAPTER2_API UUserProfile : public UObject
UserProfile
C++ class in the Class Viewer (Window | Developer Tools | Class Viewer). Since the previously created UCLASS
does not derive from Actor
, to find your custom UCLASS
, you must turn off Filters | Actors Only in the Class Viewer (which is checked by default):Turn off the Actors Only check mark to display all the classes in the Class Viewer. If you don't do this, then your custom C++ class may not show!
UserProfile
class in the Class Viewer, right-click on it, and create a Blueprint from it by selecting Create Blueprint…BP_
. You may choose to follow this convention or not, just be sure to be consistent.UserProfile
Blueprint instance you create.18.219.228.88