1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-09 12:50:35 +00:00

Merge pull request #58617 from KoBeWi/custom_something

Improve handling of custom types
This commit is contained in:
Rémi Verschelde
2022-09-07 17:54:17 +02:00
7 changed files with 52 additions and 16 deletions

View File

@@ -509,6 +509,32 @@ Variant EditorData::instance_custom_type(const String &p_type, const String &p_i
return Variant();
}
const EditorData::CustomType *EditorData::get_custom_type_by_name(const String &p_type) const {
for (const KeyValue<String, Vector<CustomType>> &E : custom_types) {
for (const CustomType &F : E.value) {
if (F.name == p_type) {
return &F;
}
}
}
return nullptr;
}
const EditorData::CustomType *EditorData::get_custom_type_by_path(const String &p_path) const {
for (const KeyValue<String, Vector<CustomType>> &E : custom_types) {
for (const CustomType &F : E.value) {
if (F.script->get_path() == p_path) {
return &F;
}
}
}
return nullptr;
}
bool EditorData::is_type_recognized(const String &p_type) const {
return ClassDB::class_exists(p_type) || ScriptServer::is_global_class(p_type) || get_custom_type_by_name(p_type);
}
void EditorData::remove_custom_type(const String &p_type) {
for (KeyValue<String, Vector<CustomType>> &E : custom_types) {
for (int i = 0; i < E.value.size(); i++) {