summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorTomasz Chabora <kobewi4e@gmail.com>2020-07-06 00:06:37 +0200
committerTomasz Chabora <kobewi4e@gmail.com>2020-07-06 00:06:37 +0200
commit95b4f972e6f71ef366330f944820a430b272f287 (patch)
treeef07173683efe36b501b71d7a775a9fc3e1f1654 /editor
parentc95fbd50fef4f648fef28e9435726a40ee7b7e2e (diff)
Support built-in scripts for inspector categories
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_inspector.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 7742382048..cf32ffb4e0 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -1592,7 +1592,9 @@ void EditorInspector::update_tree() {
}
}
if (category->icon.is_null()) {
- category->icon = EditorNode::get_singleton()->get_class_icon(type, "Object");
+ if (type != String()) { // Can happen for built-in scripts.
+ category->icon = EditorNode::get_singleton()->get_class_icon(type, "Object");
+ }
}
category->label = type;
@@ -2405,9 +2407,12 @@ void EditorInspector::_update_script_class_properties(const Object &p_object, Li
String n = EditorNode::get_editor_data().script_class_get_name(script->get_path());
if (n.length()) {
classes.push_front(n);
- } else {
+ } else if (script->get_path() != String() && script->get_path().find("::") == -1) {
n = script->get_path().get_file();
classes.push_front(n);
+ } else {
+ n = TTR("Built-in script");
+ classes.push_front(n);
}
paths[n] = script->get_path();
script = script->get_base_script();
@@ -2436,7 +2441,14 @@ void EditorInspector::_update_script_class_properties(const Object &p_object, Li
for (List<StringName>::Element *E = classes.front(); E; E = E->next()) {
StringName name = E->get();
String path = paths[name];
- Ref<Script> s = ResourceLoader::load(path, "Script");
+ Ref<Script> s;
+ if (path == String()) {
+ // Built-in script. It can't be inherited, so must be the script attached to the object.
+ s = p_object.get_script();
+ } else {
+ s = ResourceLoader::load(path, "Script");
+ }
+ ERR_FAIL_COND(!s->is_valid());
List<PropertyInfo> props;
s->get_script_property_list(&props);