"Local To Scene" doesn't work as expected

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By GarlicSource

Say I have a single meshInstance saved as scene1.tscn. The mesh (mesh1) of this meshInstance has a surface assigned with material mat1.

Now I instantiate several scene1 and attempt to change their material color respectively. In the inspector, I checked both “Local To Scene” boxes under Resource panel for mesh1 and mat1.

But when the code triggers color change on one of the instances, all instances of scene1 change color.

What I’m missing here?

:bust_in_silhouette: Reply From: ArdaE

I’m assuming you must be using an imported mesh. Try selecting Make Unique on the Mesh before enabling Local to Scene for it or anything it contains such as the materials you’re modifying. Otherwise, while the Editor shows the Local to Scene option checked, the state of the option doesn’t persist (it doesn’t get saved anywhere, so it doesn’t take effect in your game and is lost even in the editor the next time you load the project).

It’d be better if Godot greyed out such uneditable/non-persistent options so confusion like this is avoided, but it doesn’t (yet).

Thanks for your answer.

That sounds like the reason - I did import my own mesh created in Blender. I’ll give it a try once I got chance.

Thank you again :slight_smile:

GarlicSource | 2021-04-14 08:30

I had the same problem. Thanks for the help and clarification. However, in addition to selecting ‘Make Unique’, I also had to make a copy of the material and explicitly setting it back, after any modifications:

var mat = blob.mesh.surface_get_material(0)
mat.albedo_color = some_color
blob.mesh.surface_set_material(0, mat.duplicate())

I don’t know if this is an intended procedure, or a small bug somewhere.

uaknight | 2022-02-20 09:02

I clicked “make unique” and I enabled “local to scene” and it still didn’t work

PizzaMaker | 2022-10-30 21:35