Runtime Prefab material updates its changes to prefab definition

Not sure this is a bug but in general the settings you change in the inspectors during run/debug, don’t make their way into your project settings, but I found that If I create a prefab instance in code, then any changes I make to its materials in the inspector during debuging, directly affect that material and the prefab even on the next run.

Feels kind of dangerous because you always assume you automatically undo all test settings after the debug session ends, but maybe materials aren’t changed in memory but directly on disc?

Hi,

It depends on how you access the material. The sharedMaterial property is a reference to the material on disk.

Hmm, I’m setting the albedo of the shader component in the inspector of a skinned mesh renderer of a runtime instantiated prefab.

The material shown in the inspector is the sharedMaterial. By that I mean that is the asset on disk and if you change this in the inspector all objects using this material will change.

Thanks, that’s really good to know.

If I access the shared material of a skinned Mesh Renderer of a prefab through code, does that also mean the material changes on disk?

yes it does.