summaryrefslogtreecommitdiff
path: root/modules/navigation
diff options
context:
space:
mode:
Diffstat (limited to 'modules/navigation')
-rw-r--r--modules/navigation/register_types.cpp22
-rw-r--r--modules/navigation/register_types.h6
2 files changed, 19 insertions, 9 deletions
diff --git a/modules/navigation/register_types.cpp b/modules/navigation/register_types.cpp
index 218f2c2937..62ae2c7f02 100644
--- a/modules/navigation/register_types.cpp
+++ b/modules/navigation/register_types.cpp
@@ -51,21 +51,29 @@ NavigationServer3D *new_server() {
return memnew(GodotNavigationServer);
}
-void register_navigation_types() {
- NavigationServer3DManager::set_default_server(new_server);
+void initialize_navigation_module(ModuleInitializationLevel p_level) {
+ if (p_level == MODULE_INITIALIZATION_LEVEL_SERVERS) {
+ NavigationServer3DManager::set_default_server(new_server);
#ifndef _3D_DISABLED
- _nav_mesh_generator = memnew(NavigationMeshGenerator);
- GDREGISTER_CLASS(NavigationMeshGenerator);
- Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationMeshGenerator", NavigationMeshGenerator::get_singleton()));
+ _nav_mesh_generator = memnew(NavigationMeshGenerator);
+ GDREGISTER_CLASS(NavigationMeshGenerator);
+ Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationMeshGenerator", NavigationMeshGenerator::get_singleton()));
#endif
+ }
#ifdef TOOLS_ENABLED
- EditorPlugins::add_by_type<NavigationMeshEditorPlugin>();
+ if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
+ EditorPlugins::add_by_type<NavigationMeshEditorPlugin>();
+ }
#endif
}
-void unregister_navigation_types() {
+void uninitialize_navigation_module(ModuleInitializationLevel p_level) {
+ if (p_level != MODULE_INITIALIZATION_LEVEL_SERVERS) {
+ return;
+ }
+
#ifndef _3D_DISABLED
if (_nav_mesh_generator) {
memdelete(_nav_mesh_generator);
diff --git a/modules/navigation/register_types.h b/modules/navigation/register_types.h
index 11fa5769d7..c4dbd19ed3 100644
--- a/modules/navigation/register_types.h
+++ b/modules/navigation/register_types.h
@@ -31,7 +31,9 @@
#ifndef NAVIGATION_REGISTER_TYPES_H
#define NAVIGATION_REGISTER_TYPES_H
-void register_navigation_types();
-void unregister_navigation_types();
+#include "modules/register_module_types.h"
+
+void initialize_navigation_module(ModuleInitializationLevel p_level);
+void uninitialize_navigation_module(ModuleInitializationLevel p_level);
#endif // NAVIGATION_REGISTER_TYPES_H