Node reference added in tool script disappears in running game

Godot Version

v4.5.dev1.official [97241ffea]

Question

I have a @tool script that adds a Room node reference to an exit resource when I click a button:

@tool
class_name Exit extends Resource

var current_room: Room :
	set(room_to_set): 
		current_room = room_to_set

This resource exists in the exits dictionary in another Room node.

@tool
class_name Room extends Node

@export var exits: Dictionary[Types.ExitDirs, Exit] = {}

The Room node reference is successfully set, as tested with print. However, when the game is running, it reverts to <null>. Is there something about tool scripts that I’m missing?

Resources only save to disk @exported variables (those which usage flag contains PROPERTY_USAGE_STORAGE)

But resource won’t be able to save Nodes. Only scenes can do that. You’ll need to save another thing like the NodePath for example

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.