Added warning for unsupported types in BinarySerializer
This commit is contained in:
parent
b82507fc5c
commit
691fd26075
@ -4,6 +4,7 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace MLAPI.NetworkingManagerComponents
|
namespace MLAPI.NetworkingManagerComponents
|
||||||
{
|
{
|
||||||
@ -74,6 +75,8 @@ namespace MLAPI.NetworkingManagerComponents
|
|||||||
outputSize += Encoding.UTF8.GetByteCount((string)sortedFields[i].GetValue(instance)) + 2;
|
outputSize += Encoding.UTF8.GetByteCount((string)sortedFields[i].GetValue(instance)) + 2;
|
||||||
else if (sortedFields[i].FieldType == typeof(byte[]))
|
else if (sortedFields[i].FieldType == typeof(byte[]))
|
||||||
outputSize += ((byte[])sortedFields[i].GetValue(instance)).Length + 2; //Two bytes to specify the size
|
outputSize += ((byte[])sortedFields[i].GetValue(instance)).Length + 2; //Two bytes to specify the size
|
||||||
|
else
|
||||||
|
Debug.LogWarning("MLAPI: The type \"" + sortedFields[i].FieldType.Name + "\" is not supported by the Binary Serializer. It will be ignored");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Write data
|
//Write data
|
||||||
@ -187,6 +190,8 @@ namespace MLAPI.NetworkingManagerComponents
|
|||||||
ushort size = reader.ReadUInt16();
|
ushort size = reader.ReadUInt16();
|
||||||
sortedFields[i].SetValue(instance, reader.ReadBytes(size));
|
sortedFields[i].SetValue(instance, reader.ReadBytes(size));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
Debug.LogWarning("MLAPI: The type \"" + sortedFields[i].FieldType.Name + "\" is not supported by the Binary Serializer. It will be ignored");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user