diff --git a/modules/gltf/doc_classes/GLTFDocument.xml b/modules/gltf/doc_classes/GLTFDocument.xml index 1967df521881..588015de620c 100644 --- a/modules/gltf/doc_classes/GLTFDocument.xml +++ b/modules/gltf/doc_classes/GLTFDocument.xml @@ -62,10 +62,17 @@ - Registers this GLTFDocumentExtension instance with GLTFDocument. If [param first_priority] is true, this extension will be ran first. Otherwise, it will be ran last. + Registers the given [GLTFDocumentExtension] instance with GLTFDocument. If [param first_priority] is true, 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]. + + + + + Unregisters the given [GLTFDocumentExtension] instance. + + diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index faa8ed267ac7..f27e2385c6a6 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -6761,6 +6761,8 @@ void GLTFDocument::_bind_methods() { ClassDB::bind_static_method("GLTFDocument", D_METHOD("register_gltf_document_extension", "extension", "first_priority"), &GLTFDocument::register_gltf_document_extension, DEFVAL(false)); + ClassDB::bind_static_method("GLTFDocument", D_METHOD("unregister_gltf_document_extension", "extension"), + &GLTFDocument::unregister_gltf_document_extension); } void GLTFDocument::_build_parent_hierachy(Ref state) { @@ -6789,6 +6791,10 @@ void GLTFDocument::register_gltf_document_extension(Ref p } } +void GLTFDocument::unregister_gltf_document_extension(Ref p_extension) { + all_document_extensions.erase(p_extension); +} + void GLTFDocument::unregister_all_gltf_document_extensions() { all_document_extensions.clear(); } diff --git a/modules/gltf/gltf_document.h b/modules/gltf/gltf_document.h index 15099efe33e3..5a0e4ff49811 100644 --- a/modules/gltf/gltf_document.h +++ b/modules/gltf/gltf_document.h @@ -77,6 +77,7 @@ class GLTFDocument : public Resource { public: static void register_gltf_document_extension(Ref p_extension, bool p_first_priority = false); + static void unregister_gltf_document_extension(Ref p_extension); static void unregister_all_gltf_document_extensions(); private: