summaryrefslogtreecommitdiff
path: root/doc/classes
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-04-20 23:51:04 +0200
committerGitHub <noreply@github.com>2020-04-20 23:51:04 +0200
commitb372227f063fccde8e6aa26d98369c443a2652dc (patch)
treec2b73d92fee6afcab30ca6b57a4de2eb2c547179 /doc/classes
parentae92d149a3137c3b9229ff56cd047f26c5f35a2b (diff)
parent2f46f1e7b1ad132c198d031dc37cd29fe865e03b (diff)
Merge pull request #37972 from Calinou/doc-improve-resourcesaver-example
Check for errors when saving in the ResourceSaver example documentation
Diffstat (limited to 'doc/classes')
-rw-r--r--doc/classes/EditorFeatureProfile.xml2
-rw-r--r--doc/classes/PackedScene.xml12
2 files changed, 8 insertions, 6 deletions
diff --git a/doc/classes/EditorFeatureProfile.xml b/doc/classes/EditorFeatureProfile.xml
index 53db8dd293..eb03d3010f 100644
--- a/doc/classes/EditorFeatureProfile.xml
+++ b/doc/classes/EditorFeatureProfile.xml
@@ -72,7 +72,7 @@
<argument index="0" name="path" type="String">
</argument>
<description>
- Saves the editor feature profile to a file in JSON format. It can then be imported using the feature profile manager's [b]Import[/b] button or the [method load_from_file] button.
+ Saves the editor feature profile to a file in JSON format. It can then be imported using the feature profile manager's [b]Import[/b] button or the [method load_from_file] button.
</description>
</method>
<method name="set_disable_class">
diff --git a/doc/classes/PackedScene.xml b/doc/classes/PackedScene.xml
index e422545b7b..2d70dea012 100644
--- a/doc/classes/PackedScene.xml
+++ b/doc/classes/PackedScene.xml
@@ -9,23 +9,25 @@
[b]Note:[/b] The node doesn't need to own itself.
[b]Example of saving a node with different owners:[/b] The following example creates 3 objects: [code]Node2D[/code] ([code]node[/code]), [code]RigidBody2D[/code] ([code]rigid[/code]) and [code]CollisionObject2D[/code] ([code]collision[/code]). [code]collision[/code] is a child of [code]rigid[/code] which is a child of [code]node[/code]. Only [code]rigid[/code] is owned by [code]node[/code] and [code]pack[/code] will therefore only save those two nodes, but not [code]collision[/code].
[codeblock]
- # Create the objects
+ # Create the objects.
var node = Node2D.new()
var rigid = RigidBody2D.new()
var collision = CollisionShape2D.new()
- # Create the object hierarchy
+ # Create the object hierarchy.
rigid.add_child(collision)
node.add_child(rigid)
- # Change owner of rigid, but not of collision
+ # Change owner of `rigid`, but not of `collision`.
rigid.owner = node
var scene = PackedScene.new()
- # Only node and rigid are now packed
+ # Only `node` and `rigid` are now packed.
var result = scene.pack(node)
if result == OK:
- ResourceSaver.save("res://path/name.scn", scene) # Or "user://..."
+ var error = ResourceSaver.save("res://path/name.scn", scene) # Or "user://..."
+ if error != OK:
+ push_error("An error occurred while saving the scene to disk.")
[/codeblock]
</description>
<tutorials>