Improve ResourceLoader.get_dependencies()'s description

This commit is contained in:
Haoyu Qiu
2025-06-15 17:01:02 +08:00
parent 46c495ca21
commit 2952e6f6aa
2 changed files with 20 additions and 5 deletions

View File

@@ -45,11 +45,14 @@
<param index="0" name="path" type="String" />
<description>
Returns the dependencies for the resource at the given [param path].
[b]Note:[/b] The dependencies are returned with slices separated by [code]::[/code]. You can use [method String.get_slice] to get their components.
Each dependency is a string that can be divided into sections by [code]::[/code]. There can be either one section or three sections, with the second section always being empty. When there is one section, it contains the file path. When there are three sections, the first section contains the UID and the third section contains the fallback path.
[codeblock]
for dependency in ResourceLoader.get_dependencies(path):
print(dependency.get_slice("::", 0)) # Prints the UID.
print(dependency.get_slice("::", 2)) # Prints the path.
if dependency.contains("::"):
print(dependency.get_slice("::", 0)) # Prints the UID.
print(dependency.get_slice("::", 2)) # Prints the fallback path.
else:
print(dependency) # Prints the path.
[/codeblock]
</description>
</method>