From 98ca9161973eb0237f515f597ace88062a56db75 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Perrier Date: Mon, 10 May 2021 22:48:33 +0200 Subject: [PATCH] Int16 & Uint16 C# serialization. --- Source/Editor/Utilities/VariantUtils.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Source/Editor/Utilities/VariantUtils.cs b/Source/Editor/Utilities/VariantUtils.cs index 046ef7f54..69c102343 100644 --- a/Source/Editor/Utilities/VariantUtils.cs +++ b/Source/Editor/Utilities/VariantUtils.cs @@ -70,6 +70,10 @@ namespace FlaxEditor.Utilities variantType = VariantType.Void; else if (type == typeof(bool)) variantType = VariantType.Bool; + else if (type == typeof(short)) + variantType = VariantType.Int16; + else if (type == typeof(ushort)) + variantType = VariantType.Uint16; else if (type == typeof(int)) variantType = VariantType.Int; else if (type == typeof(uint)) @@ -245,6 +249,8 @@ namespace FlaxEditor.Utilities case VariantType.Null: return ScriptType.Null; case VariantType.Void: return new ScriptType(typeof(void)); case VariantType.Bool: return new ScriptType(typeof(bool)); + case VariantType.Int16: return new ScriptType(typeof(short)); + case VariantType.Uint16: return new ScriptType(typeof(ushort)); case VariantType.Int: return new ScriptType(typeof(int)); case VariantType.Uint: return new ScriptType(typeof(uint)); case VariantType.Int64: return new ScriptType(typeof(long)); @@ -312,6 +318,8 @@ namespace FlaxEditor.Utilities case VariantType.Null: return null; case VariantType.Void: return typeof(void); case VariantType.Bool: return typeof(bool); + case VariantType.Int16: return typeof(short); + case VariantType.Uint16: return typeof(ushort); case VariantType.Int: return typeof(int); case VariantType.Uint: return typeof(uint); case VariantType.Int64: return typeof(long); @@ -381,6 +389,8 @@ namespace FlaxEditor.Utilities case VariantType.ManagedObject: case VariantType.Void: return null; case VariantType.Bool: return stream.ReadByte() != 0; + case VariantType.Int16: return stream.ReadInt16(); + case VariantType.Uint16: return stream.ReadUInt16(); case VariantType.Int: return stream.ReadInt32(); case VariantType.Uint: return stream.ReadUInt32(); case VariantType.Int64: return stream.ReadInt64(); @@ -516,6 +526,12 @@ namespace FlaxEditor.Utilities case VariantType.Bool: stream.Write((byte)((bool)value ? 1 : 0)); break; + case VariantType.Int16: + stream.Write((short)value); + break; + case VariantType.Uint16: + stream.Write((ushort)value); + break; case VariantType.Int: stream.Write((int)value); break; @@ -690,6 +706,12 @@ namespace FlaxEditor.Utilities case VariantType.Bool: stream.WriteValue((bool)value); break; + case VariantType.Int16: + stream.WriteValue((short)value); + break; + case VariantType.Uint16: + stream.WriteValue((ushort)value); + break; case VariantType.Int: stream.WriteValue((int)value); break;