diff --git a/getting_started/workflow/export/exporting_pcks.rst b/getting_started/workflow/export/exporting_pcks.rst index 341d6033c..d1d4b2c1e 100644 --- a/getting_started/workflow/export/exporting_pcks.rst +++ b/getting_started/workflow/export/exporting_pcks.rst @@ -89,27 +89,33 @@ process will build that type of file for the chosen platform. Opening PCK files at runtime ---------------------------- -To import a PCK file, one uses a one-liner. Keep in mind, there is no -error or exception if the import fails. Instead, one might have to create some -validation code as a layer on top. The following example expects a “mod.pck” -file in the directory of the games executable. The PCK file contains a -“mod_scene.tscn” test scene in its root. +To import a PCK file, one uses the ProjectSettings singleton. The following +example expects a “mod.pck” file in the directory of the games executable. +The PCK file contains a “mod_scene.tscn” test scene in its root. .. tabs:: .. code-tab:: gdscript GDScript func _your_function(): - ProjectSettings.load_resource_pack("res://mod.pck") - # Now one can use the assets as if they had them in the project from the start - var imported_scene = load("res://mod_scene.tscn") + # This could fail if, for example, mod.pck cannot be found + var success = ProjectSettings.load_resource_pack("res://mod.pck") + + if success: + # Now one can use the assets as if they had them in the project from the start + var imported_scene = load("res://mod_scene.tscn") .. code-tab:: csharp private void YourFunction() { - ProjectSettings.LoadResourcePack("res://mod.pck"); - // Now one can use the assets as if they had them in the project from the start - var importedScene = (PackedScene)ResourceLoader.Load("res://mod_scene.tscn"); + # This could fail if, for example, mod.pck cannot be found + var success = ProjectSettings.LoadResourcePack("res://mod.pck"); + + if (success) + { + // Now one can use the assets as if they had them in the project from the start + var importedScene = (PackedScene)ResourceLoader.Load("res://mod_scene.tscn"); + } } .. warning::