Mass-editing for StaticMesh Build Settings
Ever wanted to mass-edit those StaticMesh Build Settings in the StaticMesh Editor?
Say no more!
Our Environment Artist asked me to find a solution to the longstanding problem of setting Lightmaps options on multiple StaticMesh assets at a time.
Appearently, this is a boring task he would really love to automatize somehow.
I looked through all the data and functions available in Blueprints, so I could create a Call In Editor function for him to set this stuff, but it looks like it’s not accessible from there. I’m not really a Blueprint guy (I prefer C++ for both tools and gamplay programming), so if I’ve missed something obvious, please let me know in the comments section below.
Luckily enough, Unreal Engine 4.20 has exposed a lot of useful things Editor-wise, so I decided to give it a shot and used the brand new Scripted Editor Extensions feature that comes with the latest major update.
Long story short: it can be done and it perfectly works. If you want to know how, just keep reading.
The basic idea was that of creating a Blutility Asset Action to be able to access the Lightmap generation settings, so I just created one and to my great surprise, there was a lot of data except what I was looking for:
Please note that in order to access these nodes you need to enable Editor Scripting Utilities plugin:
I then tried a different approach and delved into the engine code, searching for information about how and where that kind of data is handled.
I found out that the UStaticMesh class has a nice array of FStaticMeshSourceModel structures which can be used to alter those settings (and a lot more). In particular, it gives you access to the BuildSettings, which is an object of type FMeshBuildSettings. Here lie all the meat and potatoes for the Lightmap build settings.
I ended up creating a new class deriving from UBlueprintFunctionLibrary and added a new function like this:
I created a new AssetAction Blutility (see this tutorial for detailed information) and added this function to it:
Now if I select a bunch of StaticMesh assets in the Content Browser and righ-click on them, I’m able to call that function to mass-edit the Mesh Build Settings for the Lightmaps:
I don’t know if you’ll find this useful; our Environment Artist surely does.
I think this could be done with a couple lines of Python scripting, but I did not try.