diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 3deb1ccaab9..d0aa2247733 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -211,6 +211,7 @@ void ShaderMaterial::_get_property_list(List *p_list) const { shader->get_shader_uniform_list(&list, true); HashMap>> groups; + LocalVector>> vgroups; { HashMap> none_subgroup; none_subgroup.insert("", List()); @@ -248,6 +249,7 @@ void ShaderMaterial::_get_property_list(List *p_list) const { subgroup_map.insert("", none_subgroup); groups.insert(last_group, subgroup_map); + vgroups.push_back(Pair>(last_group, { "" })); } if (!groups[last_group].has(last_subgroup)) { @@ -260,6 +262,12 @@ void ShaderMaterial::_get_property_list(List *p_list) const { subgroup.push_back(info); groups[last_group].insert(last_subgroup, subgroup); + for (Pair> &group : vgroups) { + if (group.first == last_group) { + group.second.push_back(last_subgroup); + break; + } + } } } else { last_group = ""; @@ -277,6 +285,8 @@ void ShaderMaterial::_get_property_list(List *p_list) const { info.name = "Shader Parameters"; info.hint_string = "shader_parameter/"; groups[""][""].push_back(info); + + vgroups.push_back(Pair>("", { "" })); } PropertyInfo info = E->get(); @@ -290,21 +300,10 @@ void ShaderMaterial::_get_property_list(List *p_list) const { groups[last_group][last_subgroup].push_back(info); } - List group_names; - for (HashMap>>::Iterator group = groups.begin(); group; ++group) { - group_names.push_back(group->key); - } - group_names.sort(); - - for (const String &group_name : group_names) { - List subgroup_names; - HashMap> &subgroups = groups[group_name]; - for (HashMap>::Iterator subgroup = subgroups.begin(); subgroup; ++subgroup) { - subgroup_names.push_back(subgroup->key); - } - subgroup_names.sort(); - for (const String &subgroup_name : subgroup_names) { - List &prop_infos = subgroups[subgroup_name]; + for (const Pair> &group_pair : vgroups) { + String group = group_pair.first; + for (const String &subgroup : group_pair.second) { + List &prop_infos = groups[group][subgroup]; for (List::Element *item = prop_infos.front(); item; item = item->next()) { p_list->push_back(item->get()); }