Applying Mesh to C++ Class

Hi Everyone!

I’m trying to take in a user-created input file and construct a room based on the specifications. The hierarchy looks like this:

A Room contains a Floor and Walls which both contain Various Objects.

The problem I am running into is that I want to be able to create the static mesh in the editor for each class (floor, wall, etc), but as far as I can tell, this would require me to create a blueprint subclass. Since some classes have complex containers, math manipulations, and input parsing, I would like to keep everything confined to C++ land. Is there a way to attach a static mesh to a C++ class without create a new blueprint subclass?

Further explanation: In the room constructor, I would like to read in a file, then construct walls and a floor based on these values. The walls and floor will then construct other objects, which I would like to appear in the world after this construction.

Thanks,

Staticly (if you aim for specific asset):
Make a varable for UStaticMesh* and then in constructor place:

static ConstructorHelpers::FObjectFinder<UStaticMesh> VarbaleName(TEXT("/Path/To/Asset"));

Importent: This only work in costructor, if you palce somewhere else engine will crash on call

Dynamicly (if asset you will use is not determent):

Use FStringAssetReference varable, it works like string, you place path to asset and you can get specific asset from that path using TryLoad() or ResolveObject() (2nd function won’t work if asset is not loaded):

https://docs.unrealengine.com/latest/INT/API/Runtime/CoreUObject/Misc/FStringAssetReference/index.html

Unlike ObjectFinder you can use this anywhere. This type is actually equivalent of Asset ID you use in blueprint

To get path to asset in editor you right click selected asset and click “Copy Reference” and path will be in clipboard and you can paste it to code.