Added test support for List<int> display in editor

This commit is contained in:
Kah Wei 2022-11-10 11:01:17 +08:00
parent 717f82f231
commit e8d2179d76
1 changed files with 23 additions and 0 deletions

View File

@ -302,6 +302,29 @@ namespace SHADE
registerUndoAction(object, field, newVal, gameObj);
}
}
// Any List
else if (field->FieldType->IsGenericType && field->FieldType->GetGenericTypeDefinition() == System::Collections::Generic::List<int>::typeid->GetGenericTypeDefinition())
{
System::Type^ listType = field->FieldType->GenericTypeArguments[0];
System::Collections::IEnumerable^ listEnummerable = safe_cast<System::Collections::IEnumerable^>(field->GetValue(object));
SHEditorUI::Text(Convert::ToNative(field->Name));
SHEditorUI::SameLine();
SHEditorUI::Button("+");
SHEditorUI::Indent();
int i = 0;
for each (System::Object^ obj in listEnummerable)
{
int val = safe_cast<int>(obj);
SHEditorUI::InputInt(std::to_string(i), val, &isHovered);
SHEditorUI::SameLine();
SHEditorUI::Button("-");
++i;
}
SHEditorUI::Unindent();
}
else
{
array<System::Type^>^ interfaces = field->FieldType->GetInterfaces();