Simplify Script Variables Population
This commit is contained in:
parent
5525cd85c6
commit
5a3af1bc7d
1 changed files with 13 additions and 23 deletions
|
@ -2506,22 +2506,11 @@ void EditorInspector::_update_script_class_properties(const Object &p_object, Li
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<StringName> classes;
|
List<Ref<Script>> classes;
|
||||||
Map<StringName, String> paths;
|
|
||||||
|
|
||||||
// NodeC -> NodeB -> NodeA
|
// NodeC -> NodeB -> NodeA
|
||||||
while (script.is_valid()) {
|
while (script.is_valid()) {
|
||||||
String n = EditorNode::get_editor_data().script_class_get_name(script->get_path());
|
classes.push_front(script);
|
||||||
if (n.length()) {
|
|
||||||
classes.push_front(n);
|
|
||||||
} 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();
|
script = script->get_base_script();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2545,17 +2534,18 @@ void EditorInspector::_update_script_class_properties(const Object &p_object, Li
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<StringName> added;
|
Set<StringName> added;
|
||||||
for (List<StringName>::Element *E = classes.front(); E; E = E->next()) {
|
for (List<Ref<Script>>::Element *E = classes.front(); E; E = E->next()) {
|
||||||
StringName name = E->get();
|
Ref<Script> s = E->get();
|
||||||
String path = paths[name];
|
String path = s->get_path();
|
||||||
Ref<Script> s;
|
String name = EditorNode::get_editor_data().script_class_get_name(path);
|
||||||
if (path == String()) {
|
if (name.is_empty()) {
|
||||||
// Built-in script. It can't be inherited, so must be the script attached to the object.
|
if (!path.is_empty() && path.find("::") == -1) {
|
||||||
s = p_object.get_script();
|
name = path.get_file();
|
||||||
} else {
|
} else {
|
||||||
s = ResourceLoader::load(path, "Script");
|
name = TTR("Built-in script");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ERR_FAIL_COND(!s->is_valid());
|
|
||||||
List<PropertyInfo> props;
|
List<PropertyInfo> props;
|
||||||
s->get_script_property_list(&props);
|
s->get_script_property_list(&props);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue