REVBENT Here's a simple example to play with:
Resource class:
class_name Data extends Resource
var foo = 1
Instantiated scene class (scene.gd):
extends Node
@export var data = Data.new()
Script that does scene instantiation:
extends Node
func _ready():
var s1 = load("res://scene.tscn").instantiate()
var s2 = load("res://scene.tscn").instantiate()
print(s1.data)
print(s2.data)
You should get a printout of two different Data resource objects:
<Resource#-9223372008316730102>
<Resource#-9223372008132180722>
In the case you don't do Data.new()
in the scene script, but instead you create and assign a Data
object in the editor (to an exported property) that resource will be shared between all scene instances.
However if you enable resource_local_to_scene
flag for that resource, the engine will automatically duplicate it when instantiating the scene.