|
33 | 33 | #include "audio_stream_ogg_vorbis.h" |
34 | 34 |
|
35 | 35 | #ifdef TOOLS_ENABLED |
| 36 | +#include "editor/editor_node.h" |
36 | 37 | #include "resource_importer_ogg_vorbis.h" |
| 38 | + |
| 39 | +static void _editor_init() { |
| 40 | + Ref<ResourceImporterOggVorbis> ogg_vorbis_importer; |
| 41 | + ogg_vorbis_importer.instantiate(); |
| 42 | + ResourceFormatImporter::get_singleton()->add_importer(ogg_vorbis_importer); |
| 43 | +} |
37 | 44 | #endif |
38 | 45 |
|
39 | 46 | void initialize_vorbis_module(ModuleInitializationLevel p_level) { |
40 | | - if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) { |
41 | | - return; |
| 47 | + if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) { |
| 48 | + GDREGISTER_CLASS(AudioStreamOggVorbis); |
| 49 | + GDREGISTER_CLASS(AudioStreamPlaybackOggVorbis); |
42 | 50 | } |
43 | 51 |
|
44 | 52 | #ifdef TOOLS_ENABLED |
45 | | - if (Engine::get_singleton()->is_editor_hint()) { |
46 | | - Ref<ResourceImporterOggVorbis> ogg_vorbis_importer; |
47 | | - ogg_vorbis_importer.instantiate(); |
48 | | - ResourceFormatImporter::get_singleton()->add_importer(ogg_vorbis_importer); |
49 | | - } |
50 | | - |
51 | | - ClassDB::APIType prev_api = ClassDB::get_current_api(); |
52 | | - ClassDB::set_current_api(ClassDB::API_EDITOR); |
| 53 | + if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) { |
| 54 | + GDREGISTER_CLASS(ResourceImporterOggVorbis); |
53 | 55 |
|
54 | | - // Required to document import options in the class reference. |
55 | | - GDREGISTER_CLASS(ResourceImporterOggVorbis); |
56 | | - |
57 | | - ClassDB::set_current_api(prev_api); |
| 56 | + EditorNode::add_init_callback(_editor_init); |
| 57 | + } |
58 | 58 | #endif |
59 | | - |
60 | | - GDREGISTER_CLASS(AudioStreamOggVorbis); |
61 | | - GDREGISTER_CLASS(AudioStreamPlaybackOggVorbis); |
62 | 59 | } |
63 | 60 |
|
64 | 61 | void uninitialize_vorbis_module(ModuleInitializationLevel p_level) { |
65 | | - if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) { |
66 | | - return; |
67 | | - } |
68 | 62 | } |
0 commit comments