The static mesh is not saved with two materials (Geometry Script)

I have a problem saving a dynamic mesh as a static mesh.
The mesh has two materials but when I save it only one is applied.
I think it’s some problem with the UVs but I have no idea how to fix it.

I am using this code to save the asset:

The asset is like this (with two materials).

But when I save it it looks like this (It also has two materials but only one of them is applied).

I thought it was a problem with UV because they are completely out of the area where they are supposed to be.

But I edited the UV map

and it does not solve the problem.

So, the problem must be something else.

Here is the example project:

GeometryScript.zip (2.7 MB)

There you can find two versions of the code, one in blueprint and one in C++ (but they are exactly the same)

The C++ source code can be found here.

This is an example video of how to use the tool (You can also see the problem of materials):

Does anyone know how to fix this?

Thank you so much!!

I’m getting two materials

Generated geo saved

In viewport the tool on the left and the newly generated static mesh on the right

2nd test

Though the blueprint version doesn’t seem to have the material settings exposed (you need to click the eye icon in the script to expose them)

Then added the save asset to the bp version and it works ok

Both versions work as expected. Not sure what is going on in your project. Maybe some old cache is throwing off the scripts?

1 Like

HI @3dRaven
Thank you very much for checking it out.

I don’t think there is anything in the cache.

I made the code the day before yesterday following this tutorial.

I delete the cache folder every day (I have it on a RAMdisk).
...\AppData\Local\UnrealEngine\Common\DerivedDataCache

Then I wrote it in C++ because the blueprints started doing weird things.

I copied everything from one blueprint to another and when I started deleting things from the second blueprint they were also deleted from the first one. Things like this are what make me distrust blueprints.

You’re using the same engine version as me, right?
UE5.4.4 Compiled from GitHub source code?

I’m going to try adding the SaveAset() function like you have in your code. Maybe that’s the problem.

Thank you so much @3dRaven

The download suggested 5.5 (seems the engine defaulted to the latest version). I’ll see if I can revert it to 5.4

Ok.. what happens is that I probably created the project with UE5.5 by accident…
But I also had the problem with 5.5… that’s where I made the video.
Don’t bother reverting the version… I have the problem with both versions then.

I will try SaveAset() function

Thank you so much!!

I think it is the engine version. (SaveAsset() didn’t work)

I just checked the project version. Theoretically it is 5.4.4

If it is the version then it is a bigger problem

Accidentally launched it in 5.3 source, works there too :slight_smile:

Make sure you check you save path. You have /Game/Game/StaticMesh as the path. Probably should be /Game/StaticMesh

I have a Game Folder inside the Game folder XD… because of Megascan. To keep everything organized. And in the end I never used Megascan. LOL

I just tried Lyra on 5.5… it has tools like this and they work…


the problem must be with version 5.4.4

I’m undecided… I feel like updating my project to version 5.5… but this version has problems with particle systems… And that’s in the normal version, the source version might have some surprises.
On the other hand, the procedural level design looks very good. It’s a big dilemma.