-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Scan for resource groups define in exported vars #9
Comments
Technically it should be possible to do so, however it would incur finding all scenes in the project, then opening every scene, instantiating it, walking over all nodes, extracting the exported properties of each node, if the node exports a resource recursively walking that resource's properties, etc. and thus finding any exported resource group, updating the resource group and then re-save the scene. There may also be editor scripts attached to nodes which may interfere with the process. This may inadvertently break scenes in the project. If scenes are particularly large it may also take a while. A similar thing would need to be done for resources which include an exported ResourceGroup. Another option would be to patch the scene/resource files low level, by parsing the tscn/tres format manually, finding entries for resource groups and patching these at text level. This would probably execute faster (though we still would need to open a lot of files in the project) and also has less chance of messing up the scenes but would require a low level tscn/resource file parser/writer which isn't exactly straightforward to implement in GDScript (I have implemented one in Python, so I know how to do it, but for Python there exists proper tooling for parser generators like ANTLR, which sadly doesn't exist for GDScript). So neither approach is particularly great. If you have another idea on how it could be done, ideally without opening every resource file and scene in the project, I'd love to hear about it. |
I’m pretty new to godot and completely new to plugins, but is there a build hook for tool scripts similar to the one I see you implement for the plugin? Such that the ResourceGroup script could itself request the scan at build time. |
I am only aware of a generic hook indicating "build starts now". And this is only called on editor plugins, so a resource group inside of a scene would not get called. |
I think I understand it better now, that the plugin has to access only files at build time and not loaded nodes. In that case, to reduce the number of files, how about creating a "ResourceAtlas", where it exports an Array[ResourceGroup] and processes each of those. You can add an id var to ResourceGroup and the atlas will insert the processed ResourceGroup into a dictionary with its id as its key for easy access (I'd say just use a dictionary from the start but as I understand it gdscript doesn't support typed Dictionaries). That way I can define all of my groups in one file. |
Yes that would be an option, however this is really so simple that its probably better done in a custom script for each project e.g.. class_name ResourceAtlas
@export var all_levels:ResourceGroup
@export var all_enemies:ResourceGroup etc.. The amount and content of the fields is of course specific to the project. |
Currently the plugin only scans for ResourceGroup resource files. Would it be possible to also scan for ResourceGroup's that are attached to exported var's in the editor via the "New ResourceGroup" option? This would allow me to avoid creating files for resource groups that will only be used in a single node.
The text was updated successfully, but these errors were encountered: