Skip to content

Commit 691fd26

Browse files
committed
Added warning for unsupported types in BinarySerializer
1 parent b82507f commit 691fd26

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

MLAPI/NetworkingManagerComponents/BinarySerializer.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Linq;
55
using System.Reflection;
66
using System.Text;
7+
using UnityEngine;
78

89
namespace MLAPI.NetworkingManagerComponents
910
{
@@ -74,6 +75,8 @@ public static byte[] Serialize<T>(T instance)
7475
outputSize += Encoding.UTF8.GetByteCount((string)sortedFields[i].GetValue(instance)) + 2;
7576
else if (sortedFields[i].FieldType == typeof(byte[]))
7677
outputSize += ((byte[])sortedFields[i].GetValue(instance)).Length + 2; //Two bytes to specify the size
78+
else
79+
Debug.LogWarning("MLAPI: The type \"" + sortedFields[i].FieldType.Name + "\" is not supported by the Binary Serializer. It will be ignored");
7780
}
7881

7982
//Write data
@@ -187,6 +190,8 @@ public static byte[] Serialize<T>(T instance)
187190
ushort size = reader.ReadUInt16();
188191
sortedFields[i].SetValue(instance, reader.ReadBytes(size));
189192
}
193+
else
194+
Debug.LogWarning("MLAPI: The type \"" + sortedFields[i].FieldType.Name + "\" is not supported by the Binary Serializer. It will be ignored");
190195
}
191196
}
192197
}

0 commit comments

Comments
 (0)