diff --git a/modules/gltf/doc_classes/GLTFDocument.xml b/modules/gltf/doc_classes/GLTFDocument.xml index 47ffc624bad9..a7497e9e5fff 100644 --- a/modules/gltf/doc_classes/GLTFDocument.xml +++ b/modules/gltf/doc_classes/GLTFDocument.xml @@ -95,6 +95,7 @@ Registers the given [GLTFDocumentExtension] instance with GLTFDocument. If [param first_priority] is [code]true[/code], this extension will be run first. Otherwise, it will be run last. [b]Note:[/b] Like GLTFDocument itself, all GLTFDocumentExtension classes must be stateless in order to function properly. If you need to store data, use the [code]set_additional_data[/code] and [code]get_additional_data[/code] methods in [GLTFState] or [GLTFNode]. + [b]Note:[/b] This method is static: Registered instances will be shared by all [GLTFDocument] instances. Beware that multiple instances of a single [GLTFDocumentExtension] class can often lead to unexpected behavior, and consider using [method get_all_gltf_document_extensions] to verify that only one instance of a given extension is registered. @@ -102,6 +103,21 @@ Unregisters the given [GLTFDocumentExtension] instance. + [b]Note:[/b] This method is static: Registering and unregistering instances will affect all [GLTFDocument] instances. + + + + + + Returns all registered [GLTFDocumentExtension] instances, including a default [GLTFDocumentExtensionConvertImporterMesh] instance at runtime. + [b]Note:[/b] This method is static: Registered instances will be shared by all [GLTFDocument] instances. Consider using this method to check if a given [GLTFDocumentExtension] is already registered. + + + + + + Unregisters all [GLTFDocumentExtension] instances, including the default [GLTFDocumentExtensionConvertImporterMesh] instance at runtime. + [b]Note:[/b] This method is static: Unregistering instances will affect all [GLTFDocument] instances. diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 6da56616b715..4ad55ac4f422 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -8152,6 +8152,8 @@ void GLTFDocument::_bind_methods() { &GLTFDocument::register_gltf_document_extension, DEFVAL(false)); ClassDB::bind_static_method("GLTFDocument", D_METHOD("unregister_gltf_document_extension", "extension"), &GLTFDocument::unregister_gltf_document_extension); + ClassDB::bind_static_method("GLTFDocument", D_METHOD("unregister_all_gltf_document_extensions"), &GLTFDocument::unregister_all_gltf_document_extensions); + ClassDB::bind_static_method("GLTFDocument", D_METHOD("get_all_gltf_document_extensions"), &GLTFDocument::_get_all_gltf_document_extensions); ClassDB::bind_static_method("GLTFDocument", D_METHOD("get_supported_gltf_extensions"), &GLTFDocument::get_supported_gltf_extensions); } @@ -8194,6 +8196,14 @@ Vector> GLTFDocument::get_all_gltf_document_extension return all_document_extensions; } +TypedArray> GLTFDocument::_get_all_gltf_document_extensions() { + TypedArray> ret; + for (Ref ext : all_document_extensions) { + ret.append(ext); + } + return ret; +} + Vector GLTFDocument::get_supported_gltf_extensions() { HashSet set = get_supported_gltf_extensions_hashset(); Vector vec; diff --git a/modules/gltf/gltf_document.h b/modules/gltf/gltf_document.h index a6d6caa3f0a7..fa68c1b156c0 100644 --- a/modules/gltf/gltf_document.h +++ b/modules/gltf/gltf_document.h @@ -85,6 +85,7 @@ class GLTFDocument : public Resource { static void unregister_gltf_document_extension(Ref p_extension); static void unregister_all_gltf_document_extensions(); static Vector> get_all_gltf_document_extensions(); + static TypedArray> _get_all_gltf_document_extensions(); static Vector get_supported_gltf_extensions(); static HashSet get_supported_gltf_extensions_hashset();