public static TrackedKey DeserializeTrackedKey(byte[] trackedAsBytes) { TrackedKey key = new TrackedKey(); key.keyDown = System.BitConverter.ToBoolean(trackedAsBytes, 0); key.keyPressed = System.BitConverter.ToBoolean(trackedAsBytes, 1); key.keyUp = System.BitConverter.ToBoolean(trackedAsBytes, 2); return(key); }
//Tracked Key Serialization Order - Always Three Bytes // - keyDown boolean, 1 byte // - keyPressed boolean, 1 byte // - keyUp boolean , 1 byte //IMPORTANT: This Serialization only serializes the required booleans which are then sent over ENS's NetworkFields. displayName,key,isNetworked,etc is not transfered over. //As of making this NetworkField's use JSON to transfer information so these aren't being used. public static byte[] SerializeTrackedKey(TrackedKey key) { List <byte> objectAsBytes = new List <byte>(); objectAsBytes.AddRange(System.BitConverter.GetBytes(key.keyDown)); objectAsBytes.AddRange(System.BitConverter.GetBytes(key.keyPressed)); objectAsBytes.AddRange(System.BitConverter.GetBytes(key.keyUp)); return(objectAsBytes.ToArray()); }