Skip to content

Commit dbec29f

Browse files
Correct ResourceFormatSaver example (#114)
1 parent 1ae773e commit dbec29f

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/recipes/resource-saver-loader.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,21 +130,15 @@ impl IResourceFormatSaver for MyAssetSaver {
130130
) -> PackedStringArray {
131131
let mut array = PackedStringArray::new();
132132

133-
// Even though the Godot docs state that you don't need this check, it is
134-
// in fact necessary.
135-
if Self::is_recognized_resource(res) {
136-
// It is also possible to add multiple extensions per Saver.
137-
array.push("myextension");
138-
}
139-
133+
// It is also possible to add multiple extensions per Saver.
134+
array.push("myextension");
140135
array
141136
}
142137

143138
// All resource types that this saver should handle must return true.
144-
fn is_recognized_resource(res: Option<Gd<Resource>>) -> bool {
139+
fn recognize(&self, res: Option<Gd<Resource>>) -> bool {
145140
// It is also possible to add multible resource types per Saver.
146-
res.expect("Godot called this without an input resource?")
147-
.is_class("MyResourceType")
141+
res.is_some_and(|r| r.is_class("MyResourceType"))
148142
}
149143

150144
// This defines your logic for actually saving your resource.

0 commit comments

Comments
 (0)