From dd8e05ed490bce895ec881558484adf4a3e26c52 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 16 Aug 2023 22:27:03 +0200 Subject: [PATCH] Add C#-only types for Variant value storage from 0cb049167ba5649789ff58a34a07b1a16e5b95f6 --- Source/Engine/Core/Types/Variant.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Source/Engine/Core/Types/Variant.cpp b/Source/Engine/Core/Types/Variant.cpp index 1a9cc6777..f1c27fe5c 100644 --- a/Source/Engine/Core/Types/Variant.cpp +++ b/Source/Engine/Core/Types/Variant.cpp @@ -2933,10 +2933,30 @@ Variant Variant::NewValue(const StringAnsiView& typeName) break; } } +#if USE_CSHARP + else if (const auto mclass = Scripting::FindClass(typeName)) + { + // Fallback to C#-only types + if (mclass->IsEnum()) + { + v.SetType(VariantType(VariantType::Enum, typeName)); + v.AsUint64 = 0; + } + else if (mclass->IsValueType()) + { + v.SetType(VariantType(VariantType::Structure, typeName)); + } + else + { + v.SetType(VariantType(VariantType::ManagedObject, typeName)); + } + } +#endif else if (typeName.HasChars()) { LOG(Warning, "Missing scripting type \'{0}\'", String(typeName)); } + v.Inline(); // Wrap in-built types return MoveTemp(v); }