diff --git a/doc/classes/EditorSpinSlider.xml b/doc/classes/EditorSpinSlider.xml index 173d76132c77..50b25ce945f0 100644 --- a/doc/classes/EditorSpinSlider.xml +++ b/doc/classes/EditorSpinSlider.xml @@ -1,8 +1,10 @@ + Godot editor's control for editing numeric values. + This [Control] node is used in the editor's Inspector dock to allow editing of numeric values. Can be used with [EditorInspectorPlugin] to recreate the same behavior. diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index d6c5bd5fcc11..6cbf4889f9b2 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -2083,426 +2083,64 @@ EditorPropertyRID::EditorPropertyRID() { ////////////// RESOURCE ////////////////////// -void EditorPropertyResource::_file_selected(const String &p_path) { - RES res = ResourceLoader::load(p_path); - - ERR_FAIL_COND_MSG(res.is_null(), "Cannot load resource from path '" + p_path + "'."); - - List prop_list; - get_edited_object()->get_property_list(&prop_list); - String property_types; - - for (List::Element *E = prop_list.front(); E; E = E->next()) { - if (E->get().name == get_edited_property() && (E->get().hint & PROPERTY_HINT_RESOURCE_TYPE)) { - property_types = E->get().hint_string; - } - } - if (!property_types.empty()) { - bool any_type_matches = false; - const Vector split_property_types = property_types.split(","); - for (int i = 0; i < split_property_types.size(); ++i) { - if (res->is_class(split_property_types[i])) { - any_type_matches = true; - break; - } - } - - if (!any_type_matches) { - EditorNode::get_singleton()->show_warning(vformat(TTR("The selected resource (%s) does not match any type expected for this property (%s)."), res->get_class(), property_types)); - } +void EditorPropertyResource::_resource_selected(const RES &p_resource) { + if (use_sub_inspector) { + bool unfold = !get_edited_object()->editor_is_section_unfolded(get_edited_property()); + get_edited_object()->editor_set_section_unfold(get_edited_property(), unfold); + update_property(); + } else { + emit_signal("resource_selected", get_edited_property(), p_resource); } - - emit_changed(get_edited_property(), res); - update_property(); } -void EditorPropertyResource::_menu_option(int p_which) { - // scene_tree->popup_centered_ratio(); - switch (p_which) { - case OBJ_MENU_LOAD: { - if (!file) { - file = memnew(EditorFileDialog); - file->connect("file_selected", this, "_file_selected"); - add_child(file); - } - file->set_mode(EditorFileDialog::MODE_OPEN_FILE); - String type = base_type; - - List extensions; - for (int i = 0; i < type.get_slice_count(","); i++) { - ResourceLoader::get_recognized_extensions_for_type(type.get_slice(",", i), &extensions); - } - - Set valid_extensions; - for (List::Element *E = extensions.front(); E; E = E->next()) { - valid_extensions.insert(E->get()); - } - - file->clear_filters(); - for (Set::Element *E = valid_extensions.front(); E; E = E->next()) { - file->add_filter("*." + E->get() + " ; " + E->get().to_upper()); - } - - file->popup_centered_ratio(); - } break; - - case OBJ_MENU_EDIT: { - RES res = get_edited_object()->get(get_edited_property()); +void EditorPropertyResource::_resource_changed(const RES &p_resource) { + // Make visual script the correct type. + Ref