Add EditorPropertyRID as read-only label showing RID

Fixes #24827.
This commit is contained in:
Rémi Verschelde 2019-01-13 15:43:25 +01:00
parent c6b587636b
commit 0b48484d49
3 changed files with 31 additions and 0 deletions

View file

@ -795,6 +795,7 @@ EditorPropertyLayers::EditorPropertyLayers() {
layers->set_hide_on_checkable_item_selection(false);
layers->connect("id_pressed", this, "_menu_pressed");
}
///////////////////// INT /////////////////////////
void EditorPropertyInteger::_value_changed(double val) {
@ -1951,6 +1952,23 @@ EditorPropertyNodePath::EditorPropertyNodePath() {
scene_tree = NULL; //do not allocate unnecessarily
}
///////////////////// RID /////////////////////////
void EditorPropertyRID::update_property() {
RID rid = get_edited_object()->get(get_edited_property());
if (rid.is_valid()) {
int id = rid.get_id();
label->set_text("RID: " + itos(id));
} else {
label->set_text(TTR("Invalid RID"));
}
}
EditorPropertyRID::EditorPropertyRID() {
label = memnew(Label);
add_child(label);
}
////////////// RESOURCE //////////////////////
void EditorPropertyResource::_file_selected(const String &p_path) {
@ -3117,6 +3135,8 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
} break; // 15
case Variant::_RID: {
EditorPropertyRID *editor = memnew(EditorPropertyRID);
add_property_editor(p_path, editor);
} break;
case Variant::OBJECT: {
EditorPropertyResource *editor = memnew(EditorPropertyResource);

View file

@ -515,6 +515,15 @@ public:
EditorPropertyNodePath();
};
class EditorPropertyRID : public EditorProperty {
GDCLASS(EditorPropertyRID, EditorProperty)
Label *label;
public:
virtual void update_property();
EditorPropertyRID();
};
class EditorPropertyResource : public EditorProperty {
GDCLASS(EditorPropertyResource, EditorProperty)

View file

@ -29,9 +29,11 @@
/*************************************************************************/
#include "editor_properties_array_dict.h"
#include "core/io/marshalls.h"
#include "editor/editor_scale.h"
#include "editor_properties.h"
bool EditorPropertyArrayObject::_set(const StringName &p_name, const Variant &p_value) {
String pn = p_name;