In the last recipe, we created a Static Mesh Component, but we didn't try to load a mesh for the Component to display. While it's possible to do this in the Editor, sometimes it is helpful to specify a default in C++.
Follow the previous recipe so you have a custom Actor
subclass with a Static Mesh Component ready.
In your Content Browser, click on the View Options button, and select Show Engine Content:
Browse to Engine Content, then BasicShapes to see the Cube we will be using in this recipe.
Add the following code to the constructor of your class:
auto MeshAsset = ConstructorHelpers::FObjectFinder<UStaticMesh>(TEXT("StaticMesh'/Engine/BasicShapes/Cube.Cube'")); if (MeshAsset.Object != nullptr) { Mesh->SetStaticMesh(MeshAsset.Object); }
Compile, and verify in the Editor that an instance of your class now has a mesh as its visual representation.