I have a static mesh member defined in a component
When I set the variable to the desired static mesh within the editor it doesn’t give me access to the materials for that static mesh to edit.
What I’m looking for is something akin to what the UStaticMeshComponent does when you change the static mesh…it refreshes the editor and gives you access to the material slots for the selected static mesh like this…
Is this easily achievable and I’m just missing some secret sauce? Or do I need to dig into the UStaticMeshComponent and replicate some “in editor” behavior?
You probably should be using a UStaticMeshComponent, UStaticMesh is the definition of the mesh itself, UStaticMeshComponent is a USceneComponent so it can be rendered in the world.
I hear ya, it just doesn’t feel suited for my use case. Essentially this is a component that will, during gameplay, dynamically allocate/spawn these static meshes to form a grid pattern. the number of needed tiles of course is unknown ahead of time (and can be none). It felt like the appropriate thing to do was to simply have a static mesh variable rather than a full blown static mesh component.
With that being said, maybe what makes sense is to have a single static mesh component defined for the CDO that acts as the template for which to create the rest of the grid. That would then allow me to, in the editor, set the static mesh along with my desired materials. I can then simply set the template to be hidden in game.
In a round about way, thanks for the bread crumb!
ok, so if you’re not rendering from this particular place, but using it as data to later create an actual StaticMeshComponent … you can change the materials on the displayed mesh after you create the component. You don’t want to be changing the materials on the actual staticmesh, as that’s basically referring to the data that’s stored on disk.
so you can have a StaticMesh property in your class, follow it up with an array of Materials, and then whenever you actually instance a StaticMeshComponent for use in the world, then also set the materials from that array.