diff --git a/editor/prop_editor_plugin.cpp b/editor/prop_editor_plugin.cpp index 7f5871b..4254558 100644 --- a/editor/prop_editor_plugin.cpp +++ b/editor/prop_editor_plugin.cpp @@ -65,15 +65,20 @@ void PropEditorPlugin::convert_scene(Node *root, const String &path) { ResourceLoader l; if (l.exists(path)) { - Ref res = l.load(path); + Ref res = l.load(path, "PropData"); - ERR_FAIL_COND((res.is_valid() && res->get_class() != "PropData")); + ERR_FAIL_COND(!res.is_valid()); + + res->copy_from(data); + + ResourceSaver s; + s.save(path, res); res.unref(); + } else { + ResourceSaver s; + s.save(path, data); } - - ResourceSaver s; - s.save(path, data); } void PropEditorPlugin::_quick_convert_button_pressed() { diff --git a/props/prop_data.cpp b/props/prop_data.cpp index b9ccde7..151efa3 100644 --- a/props/prop_data.cpp +++ b/props/prop_data.cpp @@ -112,6 +112,20 @@ void PropData::add_textures_into(Ref texture_packer) { } #endif +void PropData::copy_from(const Ref &prop_data) { + _id = prop_data->_id; + _snap_to_mesh = prop_data->_snap_to_mesh; + _snap_axis = prop_data->_snap_axis; + + _props.clear(); + + for (int i = 0; i < prop_data->_props.size(); ++i) { + _props.push_back(prop_data->_props[i]); + } + + emit_changed(); +} + PropData::PropData() { _id = 0; _snap_to_mesh = false; @@ -144,4 +158,6 @@ void PropData::_bind_methods() { #if TEXTURE_PACKER_PRESENT ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &PropData::add_textures_into); #endif + + ClassDB::bind_method(D_METHOD("copy_from", "prop_data"), &PropData::copy_from); } diff --git a/props/prop_data.h b/props/prop_data.h index 24479d2..b0dd9bb 100644 --- a/props/prop_data.h +++ b/props/prop_data.h @@ -42,7 +42,6 @@ SOFTWARE. #include "prop_data_entry.h" - #if TEXTURE_PACKER_PRESENT #include "../../texture_packer/texture_packer.h" #endif @@ -74,6 +73,8 @@ public: void add_textures_into(Ref texture_packer); #endif + void copy_from(const Ref &prop_data); + PropData(); ~PropData();