summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-11-28 10:29:23 +0100
committerGitHub <noreply@github.com>2020-11-28 10:29:23 +0100
commit53b23c6bdcba2b7d9ee36682f026c9ebf67ded66 (patch)
treedb6e92fd408e304a4fe51fc2261d10eb32450693
parent95572211bba2155a1315dbaf6e41735c10c0417b (diff)
parentf415db5b75da2c3c1ab8169ae24a18b1a3b3b56e (diff)
Merge pull request #43922 from Calinou/doc-projectsettings-globalize-path
Improve the `ProjectSettings.globalize_path()` documentation
-rw-r--r--doc/classes/ProjectSettings.xml18
1 files changed, 16 insertions, 2 deletions
diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml
index e81160b362..fa4ce9bc6d 100644
--- a/doc/classes/ProjectSettings.xml
+++ b/doc/classes/ProjectSettings.xml
@@ -96,7 +96,21 @@
<argument index="0" name="path" type="String">
</argument>
<description>
- Converts a localized path ([code]res://[/code]) to a full native OS path.
+ Returns the absolute, native OS path corresponding to the localized [code]path[/code] (starting with [code]res://[/code] or [code]user://[/code]). The returned path will vary depending on the operating system and user preferences. See [url=https://docs.godotengine.org/en/latest/tutorials/io/data_paths.html]File paths in Godot projects[/url] to see what those paths convert to. See also [method localize_path].
+ [b]Note:[/b] [method globalize_path] with [code]res://[/code] will not work in an exported project. Instead, prepend the executable's base directory to the path when running from an exported project:
+ [codeblock]
+ var path = ""
+ if OS.has_feature("editor"):
+ # Running from an editor binary.
+ # `path` will contain the absolute path to `hello.txt` located in the project root.
+ path = ProjectSettings.globalize_path("res://hello.txt")
+ else:
+ # Running from an exported project.
+ # `path` will contain the absolute path to `hello.txt` next to the executable.
+ # This is *not* identical to using `ProjectSettings.globalize_path()` with a `res://` path,
+ # but is close enough in spirit.
+ path = OS.get_executable_path().get_base_dir().plus_file("hello.txt")
+ [/codeblock]
</description>
</method>
<method name="has_setting" qualifiers="const">
@@ -129,7 +143,7 @@
<argument index="0" name="path" type="String">
</argument>
<description>
- Convert a path to a localized path ([code]res://[/code] path).
+ Returns the localized path (starting with [code]res://[/code]) corresponding to the absolute, native OS [code]path[/code]. See also [method globalize_path].
</description>
</method>
<method name="property_can_revert">