File tree Expand file tree Collapse file tree 3 files changed +17
-4
lines changed
NetworkingManagerComponents Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 1+ using System ;
2+
3+ namespace MLAPI . Attributes
4+ {
5+ /// <summary>
6+ /// The attribute to use for variables that should be automatically. replicated from Server to Client.
7+ /// </summary>
8+ [ AttributeUsage ( AttributeTargets . Field ) ]
9+ public class BinaryIgnore : Attribute
10+ {
11+
12+ }
13+ }
Original file line number Diff line number Diff line change 6666 </Reference >
6767 </ItemGroup >
6868 <ItemGroup >
69+ <Compile Include =" Attributes\BinaryIgnore.cs" />
6970 <Compile Include =" Data\FieldType.cs" />
7071 <Compile Include =" Attributes\SyncedVar.cs" />
7172 <Compile Include =" Data\NetworkPool.cs" />
Original file line number Diff line number Diff line change 1- using System ;
1+ using MLAPI . Attributes ;
22using System . Collections . Generic ;
33using System . IO ;
44using System . Linq ;
55using System . Reflection ;
66using System . Text ;
7- using UnityEngine ;
87
98namespace MLAPI . NetworkingManagerComponents
109{
@@ -37,7 +36,7 @@ public static byte[] Serialize<T>(T instance)
3736 sortedFields = cachedFields [ instance . GetType ( ) . FullName ] ;
3837 else
3938 {
40- sortedFields = instance . GetType ( ) . GetFields ( BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance ) . OrderBy ( x => x . Name ) . ToArray ( ) ;
39+ sortedFields = instance . GetType ( ) . GetFields ( BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance ) . OrderBy ( x => x . Name ) . Where ( x => ! x . IsDefined ( typeof ( BinaryIgnore ) , true ) ) . ToArray ( ) ;
4140 cachedFields . Add ( instance . GetType ( ) . FullName , sortedFields ) ;
4241 }
4342
@@ -142,7 +141,7 @@ public static byte[] Serialize<T>(T instance)
142141 sortedFields = cachedFields [ instance . GetType ( ) . FullName ] ;
143142 else
144143 {
145- sortedFields = instance . GetType ( ) . GetFields ( BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance ) . OrderBy ( x => x . Name ) . ToArray ( ) ;
144+ sortedFields = instance . GetType ( ) . GetFields ( BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance ) . OrderBy ( x => x . Name ) . Where ( x => ! x . IsDefined ( typeof ( BinaryIgnore ) , true ) ) . ToArray ( ) ;
146145 cachedFields . Add ( instance . GetType ( ) . FullName , sortedFields ) ;
147146 }
148147
You can’t perform that action at this time.
0 commit comments