Skip to content

Commit

Permalink
Improve the ProjectSettings.globalize_path() documentation
Browse files Browse the repository at this point in the history
This closes godotengine/godot-docs#4409.

(cherry picked from commit f415db5)
  • Loading branch information
Calinou authored and HEAVYPOLY committed Dec 14, 2020
1 parent 07b33a9 commit 4884266
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions doc/classes/ProjectSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,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">
Expand Down Expand Up @@ -109,7 +123,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">
Expand Down

0 comments on commit 4884266

Please sign in to comment.