Strange behavior of "local to scene"

Godot Version 4.2.1


Hello, can smb explain my, why godot creates many useless sub-resource when i set “local to scene”

for example:
I have ShaderMaterial with a shader (not local to scene) and some parameters

I attach it to my abstract scene “sc1” as material

after this I create a new inherited scene “sc2”. Close “sc2” and open again, and I get

if look from external editor I see new sub resource:
[sub_resource type=“ShaderMaterial” id=“ShaderMaterial_yg7by”]
resource_local_to_scene = true
shader = ExtResource(“2_jewuo”)

if disable locale to scene in the material all will be ok

thanks in advance!

1 Like

Idk for sure, but wouldnt each scene need its own copy of each resource to be “local to scene”?

Is that what you are seeing?

No, “local to scene” it means to create new resource instance per each scene’s instance.

But in my case godot’s editor create also new subresource (exact editor on scene reload, because if delete subresource in external editor all will be fine)

And as result at runtime I have more than 1k unique resources instead of about ten

Is this something that always happens, or only sometimes?

How can I reproduce it?

Do you have any tool scripts running?

yeah, always

here is archive this case to reproduce:

  • create and save some ShaderMaterial, make it local to scene
  • create SC1 (can with only root Node2D) and set material with saved ShaderMaterial above
  • create from SC1 new inherited scene SC2, save it.
    -close all scene tabs
    -open SC2, close and open again
    -after this you will get: in SC2 new sub_resource smth like:
    [sub_resource type=“ShaderMaterial” id=“ShaderMaterial_cglly”]
    with all shader parameters with defalut values etc

if make ShaderMaterial local_to_scene = false, then this problem won’t reproduce, but it’s not for me, because I need separete material instance for each scene instance, but not new resource