1
- namespace MLAPI . Data
1
+ using System ;
2
+ using UnityEngine ;
3
+
4
+ namespace MLAPI . Data
2
5
{
3
6
/// <summary>
4
7
/// The datatype used to classify SyncedVars
@@ -20,6 +23,48 @@ internal enum FieldType
20
23
Vector3 ,
21
24
Vector2 ,
22
25
Quaternion ,
23
- ByteArray
26
+ ByteArray ,
27
+ Invalid
28
+ }
29
+
30
+ internal static class FieldTypeHelper
31
+ {
32
+ internal static FieldType GetFieldType ( Type type )
33
+ {
34
+ if ( type == typeof ( bool ) )
35
+ return FieldType . Bool ;
36
+ else if ( type == typeof ( byte ) )
37
+ return FieldType . Byte ;
38
+ else if ( type == typeof ( double ) )
39
+ return FieldType . Double ;
40
+ else if ( type == typeof ( float ) )
41
+ return FieldType . Single ;
42
+ else if ( type == typeof ( int ) )
43
+ return FieldType . Int ;
44
+ else if ( type == typeof ( long ) )
45
+ return FieldType . Long ;
46
+ else if ( type == typeof ( sbyte ) )
47
+ return FieldType . SByte ;
48
+ else if ( type == typeof ( short ) )
49
+ return FieldType . Short ;
50
+ else if ( type == typeof ( uint ) )
51
+ return FieldType . UInt ;
52
+ else if ( type == typeof ( ulong ) )
53
+ return FieldType . ULong ;
54
+ else if ( type == typeof ( ushort ) )
55
+ return FieldType . UShort ;
56
+ else if ( type == typeof ( string ) )
57
+ return FieldType . String ;
58
+ else if ( type == typeof ( Vector3 ) )
59
+ return FieldType . Vector3 ;
60
+ else if ( type == typeof ( Vector2 ) )
61
+ return FieldType . Vector2 ;
62
+ else if ( type == typeof ( Quaternion ) )
63
+ return FieldType . Quaternion ;
64
+ else if ( type == typeof ( byte [ ] ) )
65
+ return FieldType . ByteArray ;
66
+ else
67
+ return FieldType . Invalid ;
68
+ }
24
69
}
25
70
}
0 commit comments