You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working with two resource types: RefA and RefB.
Within the RefA resource, I have an array containing elements of type RefB, declared as @export var ref_b_list: Array[RefB].
In the RefB resource, there's a simple reference to RefA, declared as @export var ref_a: RefA.
I use ResourceSaver to serialize the RefA resource. However, when I load this resource back using ResourceLoader, the ref_a reference in the RefB objects within the ref_b_list array is set to null.
This issue seems to be specific to the usage of an Array. If I replace the Array[RefB] with a single instance of RefB, the serialization and subsequent loading maintain the ref_a reference correctly.
Steps to reproduce
Create a ref_a.gd script :
class_name RefA extends Resource
@export var ref_b_list: Array[RefB]
Create a ref_b.gd script:
class_name RefB extends Resource
@export var ref_a: RefA
Create a main scene (Node) with attached script:
extends Node
func _ready():
var ref_b: RefB = RefB.new()
var ref_a: RefA = RefA.new()
ref_a.ref_b_list.append(ref_b)
ref_b.ref_a = ref_a
var result = ResourceSaver.save(ref_a, "user://test_data.res")
var loaded_ref_a = ResourceLoader.load("user://test_data.res")
print("ref_a.ref_b_list[0].ref_a=%s"% ref_a.ref_b_list[0].ref_a)
print("loaded_ref_a.ref_b_list[0].ref_a=%s"% loaded_ref_a.ref_b_list[0].ref_a)
The project basically contains what is described in step reproduction except I added a single ref_b variable as a sanity check.
When executing it you will see in the output something like :
Tested versions
Reproducible in Godot 4.2.1 stable.
This issue does not occur in versions prior to 4.2, as cyclic dependencies in resources were not functional.
System information
Godot v4.2.1.stable - Windows 10.0.22621 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2080 (NVIDIA; 31.0.15.4601) - Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz (8 Threads)
Issue description
I am working with two resource types: RefA and RefB.
Within the RefA resource, I have an array containing elements of type RefB, declared as
@export var ref_b_list: Array[RefB]
.In the RefB resource, there's a simple reference to RefA, declared as
@export var ref_a: RefA
.I use ResourceSaver to serialize the RefA resource. However, when I load this resource back using ResourceLoader, the ref_a reference in the RefB objects within the ref_b_list array is set to null.
This issue seems to be specific to the usage of an Array. If I replace the Array[RefB] with a single instance of RefB, the serialization and subsequent loading maintain the ref_a reference correctly.
Steps to reproduce
Minimal reproduction project (MRP)
bug_cross_reference.zip
The project basically contains what is described in step reproduction except I added a single ref_b variable as a sanity check.
When executing it you will see in the output something like :
The text was updated successfully, but these errors were encountered: