-
-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement an @export_lazy_resource
export annotation
#8484
Comments
@export_unloaded_resource
export annotation. @export_lazy_resource
export annotation.
Is there a reason for the type to be a param instead of just usual |
I'm not sure. It made sense to me when writing it, but that might make more sense. That's why this is a proposal, community discussion. |
I am not sure how feasible it is to implement. Even if you export lazy, the resource has to be listed in scene dependencies, which are automatically loaded with the scene. Deferring it would require some core changes to scene loader. |
I thought that |
|
Regarding the specific changes in It'd require a sibling to I went into a bit more depth in my proposal of what I think is the same thing (#8483). (Both proposals were made within hours of each other, so apparently @IntangibleMatter and I share a brain.) |
Created a plugin that may be helpful: |
@export_lazy_resource
export annotation. @export_lazy_resource
export annotation
Looks like godotengine/godot#97912 will cover this. |
Describe the project you are working on
A world with many deeply interconnected levels.
Describe the problem or limitation you are having in your project
My game has a lot of exits to other levels. Because these exits usually go both ways, they usually want to hold a reference to the other level. This causes a cyclic dependency, making both levels unopenable until you fix them in a text editor, removing the reference.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
@export_lazy_resource
would export a reference to a resource, but not load it until requested by the script. This means that any sort of cyclic dependency issue that doesn’t actually require the resource to be loaded can be resolved, and the person writing the code can then manually use the resource however it might need the be used.Additionally (though this is just one idea of how to handle it), there could be a new
lazyload()
function in the vein of load and preload, where it keeps a reference to the resource without actually loading it into memory.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
It would be used similarly to other export annotations, though likely with an optional type specifier. For example
@export_lazy_resource(type: Resource) var next_scene
.Then, when you need to actually load the resource, you could pass it up to a higher node who actually does the loading, or you could use the fact that its reference to the current scene isn’t actually loaded, allowing you to do something like this:
If this enhancement will not be used often, can it be worked around with a few lines of script?
This would be used frequently by many Godot users I suspect, as many level-based games want to maintain references to each other.
Currently I’m keeping a string as a path to the next room, but this is fallable, as a room could be renamed or moved. Another more robust solution can be seen here, but this is a bit ugly and not very convenient.
Is there a reason why this should be core and not an add-on in the asset library?
It involves core functionality around loading assets.
The text was updated successfully, but these errors were encountered: