Building StaticMeshes at runtime

Hello everybody,
I’m trying to convert procedural meshes to StaticMeshes at runtime. The main reason is that Lumen doesn’t support procedural meshes. I put the required code in a simple plugin.
Here is a bare-bones version of the code that runs perfectly in the editor:

and it works fine inside editor. However I get this error when I package the game:

Capture

So, I switched to a “Development Editor” but I got this:

Now I have a couple of questions:

  1. Obviously, why doesn’t the editor build run correctly?

  2. Can I safely change UE5 code in “Engine/Source/Runtime/Engine/Private/StaticMesh.cpp” , as shown below, to remove the highlighted “#if !WITH_EDITOR” block and avoid fast building the StaticMesh? (fast-built static meshes are no different from procedural meshes as far as Lumen is concerned)

  1. Even better, is there any other way to generate Lumen compliant arbitrary meshes at run time?

Thanks

Hi there @supermtf20,

This topic has been moved from International to Programming & Scripting: C++.

When posting, please review the categories to ensure your topic is posted in the most relevant space. Hopefully, this category change will help you to get an answer.

In the meantime, good luck and happy developing! :slight_smile:

1 Like

While I’m not sure about the solution to your lumen problem, you can’t use UStaticMesh::Build outside of the engine. Unreal doesn’t ship with the necessary resources.
image

Sorry for posting in the wrong place. Haven’s posted anything in while :slight_smile:

According to the Error message, you should be able to do that in an editor build, which still gave errors. That’s what I’m trying to understand and find a solution for.

and it works fine inside editor. However I get this error when I package the game:

If I understand you right, that’s more or less what I’d expect.

The static mesh build logic is, so far as I know, reliant on a lot of support code that would be wasted space in the shipping game; I believe that functionality is meant for editor plugins that allow you to generate/import/alter static meshes, where you would generate it once and then save the resulting asset into the game Content for later use. Hence why it is listed as for editor builds only.

If you package the game, you are no longer working with an editor build; if you run the executable for the packaged game, you run the game rather than the editor. Thus, none of the editor modules are loaded (or present).

Here’s the list of packaged build types:
image

There is a development build, debug build, and shipping build. There is no such thing as a packaged editor build. What it means when it says non-editor build is anything that isn’t the Unreal Engine editor itself.

To clarify, this is the editor:

Unreal Engine does not, in any configuration, package the resources required to transform a procedural mesh into a static mesh.

Although we can’t help with this issue, maybe you could clarify what you are trying to do by transforming a procedural mesh into a static mesh. There might be another method to accomplish it.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.