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 66
66
</Reference >
67
67
</ItemGroup >
68
68
<ItemGroup >
69
+ <Compile Include =" Attributes\BinaryIgnore.cs" />
69
70
<Compile Include =" Data\FieldType.cs" />
70
71
<Compile Include =" Attributes\SyncedVar.cs" />
71
72
<Compile Include =" Data\NetworkPool.cs" />
Original file line number Diff line number Diff line change 1
- using System ;
1
+ using MLAPI . Attributes ;
2
2
using System . Collections . Generic ;
3
3
using System . IO ;
4
4
using System . Linq ;
5
5
using System . Reflection ;
6
6
using System . Text ;
7
- using UnityEngine ;
8
7
9
8
namespace MLAPI . NetworkingManagerComponents
10
9
{
@@ -37,7 +36,7 @@ public static byte[] Serialize<T>(T instance)
37
36
sortedFields = cachedFields [ instance . GetType ( ) . FullName ] ;
38
37
else
39
38
{
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 ( ) ;
41
40
cachedFields . Add ( instance . GetType ( ) . FullName , sortedFields ) ;
42
41
}
43
42
@@ -142,7 +141,7 @@ public static byte[] Serialize<T>(T instance)
142
141
sortedFields = cachedFields [ instance . GetType ( ) . FullName ] ;
143
142
else
144
143
{
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 ( ) ;
146
145
cachedFields . Add ( instance . GetType ( ) . FullName , sortedFields ) ;
147
146
}
148
147
You can’t perform that action at this time.
0 commit comments