Fixed performance issue in scripts editor when multiple attributes are applied onto script fields

This commit is contained in:
Kah Wei 2022-11-09 10:31:30 +08:00
parent 349f4a875b
commit a3fe98317d
1 changed files with 3 additions and 12 deletions

View File

@ -414,19 +414,10 @@ namespace SHADE
generic<typename Attribute>
Attribute Editor::hasAttribute(System::Reflection::FieldInfo^ field)
{
array<System::Object^>^ attributes = field->GetCustomAttributes(true);
for each (System::Object^ attrib in attributes)
array<System::Object^>^ attributes = field->GetCustomAttributes(Attribute::typeid, false);
if (attributes->Length > 0)
{
try
{
Attribute attribute = safe_cast<Attribute>(attrib);
if (attribute != nullptr)
return attribute;
}
catch (System::InvalidCastException^)
{
continue;
}
return safe_cast<Attribute>(attributes[0]);
}
// Failed to find
return Attribute{};