aboutsummaryrefslogtreecommitdiff
path: root/editor/editor_data.cpp
diff options
context:
space:
mode:
authorJuan Linietsky2018-04-08 11:49:34 -0300
committerGitHub2018-04-08 11:49:34 -0300
commit2f4f8de459f8b45a3a80018753f0fa24dc138809 (patch)
tree89e8f39f43b0f76c18ad7d068e0864bfc290ec5a /editor/editor_data.cpp
parent2ba01613a3a77a212af83034311015c91b0c6759 (diff)
parent97e77688bb97e5930525ba14c884c3a9e6fc73d5 (diff)
downloadgodot-2f4f8de459f8b45a3a80018753f0fa24dc138809.tar.gz
godot-2f4f8de459f8b45a3a80018753f0fa24dc138809.tar.zst
godot-2f4f8de459f8b45a3a80018753f0fa24dc138809.zip
Merge pull request #16995 from mrcdk/custom_resources_inspector
The inspector will show the custom resources added via plugin
Diffstat (limited to '')
-rw-r--r--editor/editor_data.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp
index 95ed40d88..ef9265ecd 100644
--- a/editor/editor_data.cpp
+++ b/editor/editor_data.cpp
@@ -452,6 +452,31 @@ void EditorData::add_custom_type(const String &p_type, const String &p_inherits,
custom_types[p_inherits].push_back(ct);
}
+Object *EditorData::instance_custom_type(const String &p_type, const String &p_inherits) {
+
+ if (get_custom_types().has(p_inherits)) {
+
+ for (int i = 0; i < get_custom_types()[p_inherits].size(); i++) {
+ if (get_custom_types()[p_inherits][i].name == p_type) {
+ Ref<Texture> icon = get_custom_types()[p_inherits][i].icon;
+ Ref<Script> script = get_custom_types()[p_inherits][i].script;
+
+ Object *ob = ClassDB::instance(p_inherits);
+ ERR_FAIL_COND_V(!ob, NULL);
+ if (ob->is_class("Node")) {
+ ob->call("set_name", p_type);
+ }
+ ob->set_script(script.get_ref_ptr());
+ if (icon.is_valid())
+ ob->set_meta("_editor_icon", icon);
+ return ob;
+ }
+ }
+ }
+
+ return NULL;
+}
+
void EditorData::remove_custom_type(const String &p_type) {
for (Map<String, Vector<CustomType> >::Element *E = custom_types.front(); E; E = E->next()) {