diff options
-rw-r--r-- | editor/editor_node.cpp | 4 | ||||
-rw-r--r-- | editor/import/resource_importer_scene.cpp | 23 | ||||
-rw-r--r-- | editor/import/resource_importer_scene.h | 10 | ||||
-rw-r--r-- | scene/resources/scene_format_text.cpp | 2 | ||||
-rw-r--r-- | scene/resources/scene_format_text.h | 4 |
5 files changed, 43 insertions, 0 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 2f0c41c6e1..98991cd7c0 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -4815,6 +4815,10 @@ EditorNode::EditorNode() { Ref<EditorSceneImporterGLTF> import_gltf; import_gltf.instance(); import_scene->add_importer(import_gltf); + + Ref<EditorSceneImporterESCN> import_escn; + import_escn.instance(); + import_scene->add_importer(import_escn); } Ref<ResourceImporterBitMap> import_bitmap; diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 060953d36a..44948b8209 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -46,6 +46,7 @@ #include "scene/resources/box_shape.h" #include "scene/resources/plane_shape.h" #include "scene/resources/ray_shape.h" +#include "scene/resources/scene_format_text.h" #include "scene/resources/sphere_shape.h" uint32_t EditorSceneImporter::get_import_flags() const { @@ -1395,3 +1396,25 @@ ResourceImporterScene *ResourceImporterScene::singleton = NULL; ResourceImporterScene::ResourceImporterScene() { singleton = this; } +/////////////////////////////////////// + +uint32_t EditorSceneImporterESCN::get_import_flags() const { + return IMPORT_SCENE; +} +void EditorSceneImporterESCN::get_extensions(List<String> *r_extensions) const { + r_extensions->push_back("escn"); +} +Node *EditorSceneImporterESCN::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { + + Error error; + Ref<PackedScene> ps = ResourceFormatLoaderText::singleton->load(p_path, p_path, &error); + ERR_FAIL_COND_V(!ps.is_valid(), NULL); + + Node *scene = ps->instance(); + ERR_FAIL_COND_V(!scene, NULL); + + return scene; +} +Ref<Animation> EditorSceneImporterESCN::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) { + ERR_FAIL_V(Ref<Animation>()); +} diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index d5f9d53e91..9c3ec7a29b 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -155,4 +155,14 @@ public: ResourceImporterScene(); }; +class EditorSceneImporterESCN : public EditorSceneImporter { + GDCLASS(EditorSceneImporterESCN, EditorSceneImporter); + +public: + virtual uint32_t get_import_flags() const; + virtual void get_extensions(List<String> *r_extensions) const; + virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = NULL); + virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps); +}; + #endif // RESOURCEIMPORTERSCENE_H diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp index 0faa0dc770..91c801c016 100644 --- a/scene/resources/scene_format_text.cpp +++ b/scene/resources/scene_format_text.cpp @@ -1312,6 +1312,8 @@ Error ResourceFormatLoaderText::rename_dependencies(const String &p_path, const return ria->rename_dependencies(f, p_path, p_map); } +ResourceFormatLoaderText *ResourceFormatLoaderText::singleton = NULL; + Error ResourceFormatLoaderText::convert_file_to_binary(const String &p_src_path, const String &p_dst_path) { Error err; diff --git a/scene/resources/scene_format_text.h b/scene/resources/scene_format_text.h index c014b9bfae..c28ded3d77 100644 --- a/scene/resources/scene_format_text.h +++ b/scene/resources/scene_format_text.h @@ -128,7 +128,9 @@ public: }; class ResourceFormatLoaderText : public ResourceFormatLoader { + public: + static ResourceFormatLoaderText *singleton; virtual Ref<ResourceInteractiveLoader> load_interactive(const String &p_path, const String &p_original_path = "", Error *r_error = NULL); virtual void get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const; virtual void get_recognized_extensions(List<String> *p_extensions) const; @@ -138,6 +140,8 @@ public: virtual Error rename_dependencies(const String &p_path, const Map<String, String> &p_map); static Error convert_file_to_binary(const String &p_src_path, const String &p_dst_path); + + ResourceFormatLoaderText() { singleton = this; } }; class ResourceFormatSaverTextInstance { |