Added BinaryIgnore attribute to ignore fields on BinarySerialization
This commit is contained in:
parent
901f87dfd5
commit
27eff96223
13
MLAPI/Attributes/BinaryIgnore.cs
Normal file
13
MLAPI/Attributes/BinaryIgnore.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace MLAPI.Attributes
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The attribute to use for variables that should be automatically. replicated from Server to Client.
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Field)]
|
||||||
|
public class BinaryIgnore : Attribute
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -66,6 +66,7 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Attributes\BinaryIgnore.cs" />
|
||||||
<Compile Include="Data\FieldType.cs" />
|
<Compile Include="Data\FieldType.cs" />
|
||||||
<Compile Include="Attributes\SyncedVar.cs" />
|
<Compile Include="Attributes\SyncedVar.cs" />
|
||||||
<Compile Include="Data\NetworkPool.cs" />
|
<Compile Include="Data\NetworkPool.cs" />
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
using System;
|
using MLAPI.Attributes;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
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
|
||||||
{
|
{
|
||||||
@ -37,7 +36,7 @@ namespace MLAPI.NetworkingManagerComponents
|
|||||||
sortedFields = cachedFields[instance.GetType().FullName];
|
sortedFields = cachedFields[instance.GetType().FullName];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sortedFields = instance.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).OrderBy(x => x.Name).ToArray();
|
sortedFields = instance.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).OrderBy(x => x.Name).Where(x => !x.IsDefined(typeof(BinaryIgnore), true)).ToArray();
|
||||||
cachedFields.Add(instance.GetType().FullName, sortedFields);
|
cachedFields.Add(instance.GetType().FullName, sortedFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +141,7 @@ namespace MLAPI.NetworkingManagerComponents
|
|||||||
sortedFields = cachedFields[instance.GetType().FullName];
|
sortedFields = cachedFields[instance.GetType().FullName];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sortedFields = instance.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).OrderBy(x => x.Name).ToArray();
|
sortedFields = instance.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).OrderBy(x => x.Name).Where(x => !x.IsDefined(typeof(BinaryIgnore), true)).ToArray();
|
||||||
cachedFields.Add(instance.GetType().FullName, sortedFields);
|
cachedFields.Add(instance.GetType().FullName, sortedFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user