|Topic was automatically imported from the old Question2Answer platform.
In a tool script, I need to get the resource path of the tscn file of the current scene. Something like this (mockup code):
var res_path = get_tree().edited_scene_root.get_resource_path()
A more in depth explanation:
I want to build a workflow like this:
- Creating/editing some images in a drawing program
- Saving thoses images in a folder within the game project hierarchy
- Creating a json file at the same location to add some data about each image (size, position, etc.)
- In Godot: creating/saving a scene at the same location
- Adding a node with my tool script attached
- From the tool script, loading the json file and creating some sprites using the data read from the json file and the images present in the folder
- Later, after changing the images and the json file, using the tool script to update the created sprites
The idea here is to work relatively to the scene file because I will need to create a lot of setup like that in my game so I can’t rely on a fix absolute path for the images and json files. And I need to automate this task because I will have a lot of scene to produce and update.
The problem I’m facing is to access the json file: I haven’t found a way to get/build its path.
doesn’t fit my needs because the script of the root node is not guaranteed to be in the correct folder.
Thank you for your help!