Pass a static mesh into a blueprint variable?

Hello!

I am creating a blueprint class and would like to be able to select a static mesh type (?) and pass it in as a variable. I would then like to add it as a component via the Construction Script. I see that it is possible to use a Static Mesh variable to select a pre-existing SM in the level, but I would like to pass a type?/path?/class? of a mesh via a dropdown (exact same behavior of the Static Mesh drop-down of the Add Static Mesh Component node).

My apologies for not knowing the proper terminology :slight_smile:

Thanks!

There are three distinct types of “Static Mesh” things that should not be confused.

Static Mesh = An actual static mesh asset you see in the content browser.

Static Mesh Actor = What is created when you drop a static mesh from the content browser into the world. This is a basic actor that contains the static mesh.

Static Mesh Component = A “container” similar to the Static Mesh Actor, but as a component to put in blueprints.

The variable you created was probably a Static Mesh Actor, so it’s normal that it will only show stuff in your level as the possible choices. You want that variable to be a Static Mesh.

Then you can take the Static Mesh Component in your Blueprint and do Set Static Mesh on it, and pass it the Static Mesh variable.

Small correction Static Mesh Component is what represents static mesh on the level, there is no other way to place static mesh on the level, Static Mesh Actor is a empty actor containing Static Mesh Component which contains Static Mesh pointer.

Static mesh as a asset is contained as StaticMesh class object (UStaticMesh in C++), if you make StaticMesh varable you will be you will see mesh selection option in property editor (or dropdown that you mentioning if it’s a function argument) and you can use (since those variables point to asset insted of being one) to set StaticMesh in StaticMeshComponent.

In general all assets are normal UObjects (no diffrent from Actor, Pawn etc.) that are just marked as assets and can be stored in file as resource and reloaded anytime, so each asset type has a class corresponding to it and if you make object varable of that class in property editor you will be presented by asset selection menu.

As mentioned by JParent, note that StaticMesh only contains the mesh data, in order to materialize it in level you need StaticMeshComponent which makes renderer draw that mesh on screen