Replies: 2 comments
-
I wonder if UIDs will make this easier to do, maybe it's something planned? In any case the current limitation has often bothered me, and it would be nice to have an automatic update of the exported file paths. |
Beta Was this translation helpful? Give feedback.
-
Should this be a discussion or an issue? I'm also running into an issue with resources being referenced and loaded as a resource, but with importer settings. Storing a reference to a resource inside of the default preset for an importer causes the whole project to fail to load: godotengine/godot#83316 Other related issues: |
Beta Was this translation helpful? Give feedback.
-
Context
I'm creating a GameState system where each GameState is a custom resource. I would like each GameState to know which Scene to load when it becomes active and to also know which other GameState to switch to when the escape key is pressed.
Example code:
The Problem
1. Resources that are properties of a resource seem to be auto-loaded when that resource is loaded
In this case,
scene
is auto-loaded when theGameState
is loaded. This is not ideal because I want all of theGameState
s to be loaded, but only the currently activeGameState
'sscene
to be loaded.2. Resource properties cannot create circular references
During gameplay, I want pressing escape to open a pause menu. Then pressing escape again should close the pause menu and return to gameplay.
To do that, I would create two
GameState
s:GameState
withescape_state
set to a Pause_MenuGameState
GameState
withescape_state
set to the GameplayGameState
This cannot be done and causes this error to appear:
Possible Solution
An
@export_ref
annotation for aString
property that stores the path of the resource, but the benefit would be that the path updates if the resource is moved or renamed to allow for easy refactoring. At runtime, the resource can be loaded from the path as needed.Alternatives
scene
andescape_state
could be changed toString
and set to the paths of their resources, but that would not support moving or renaming resources and would make refactoring difficult.Beta Was this translation helpful? Give feedback.
All reactions