Can't save [map_name]: Graph is linked to external private object.

I’m making skybox generator that spawns skybox, clouds, sun, fog volume etc. right in the editor. It’s based on BrushBuilder class, but instead of changing shape of the builder brush, it spawns all this stuff. So, I was going to add a previewer, that changes skybox to the needed time of day, allowing designers to see results of their work in the editor without having to run the game after every change. The thing is that I need to create material instances and assign them to skybox mesh.


MeshMaterial = StaticMeshActors*.StaticMesh.StaticMeshComponent.GetMaterial(StaticMeshActors*.Materials[j].MatID);
StaticMeshActors*.Materials[j].MatInst = new(None) Class'MaterialInstanceConstant';
StaticMeshActors*.Materials[j].MatInst.SetParent(MeshMaterial);
StaticMeshActors*.StaticMesh.StaticMeshComponent.SetMaterial(StaticMeshActors*.Materials[j].MatID, StaticMeshActors*.Materials[j].MatInst);

That works both in the editor and when the game is running, but calling this code in the editor, leads to a problem. With material instances created in the editor, I cannot save the map or play it because of this error:

The reason is clear - meshes have this thing assigned to Materials array:


MaterialInstanceConstant'Transient.MaterialInstanceConstant_101'

Is there anything I can do to fix that problem? Maybe I’m just creating material instances in a wrong way? I could try to make another script that clears transient instances, but having to use it every time one needs to save or run the level would be really annoying.

the Material Instance is an object in memory (transient) which isn’t stored in a level, therefore you can’t save it. this leads to the object using it not being able to be saved either

this comes from you creating it like this:
new**(None)** Class’MaterialInstanceConstant’;
so None is the owner. this means the object in case (the material instance) isn’t owned by anyone, therefore the editor doesn’t even know where it should be saved

I’m not even sure what you want will work, but try at least using an Owner for it

Thanks a lot, that actually worked! I just assigned skybox controller to all instances and the error has gone.