SHARE
TWEET

Untitled

a guest Feb 19th, 2020 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public byte [] SerializeDeviceButtonMapping(int[] buttons)
  2.     {
  3.         MemoryStream ms = new MemoryStream();
  4.         BinaryWriter writer = new BinaryWriter(ms);
  5.  
  6.         Debug.Log(buttons.Length + " buttons lenght");
  7.  
  8.         for (int i = 0; i < buttons.Length; i++)
  9.         {
  10.             writer.Write(buttons[i]);
  11.            
  12.         }
  13.  
  14.         return ms.ToArray();
  15.     }
  16.  
  17.     public int[] DeserializeDeviceButtonMapping(byte[] bytes)
  18.     {
  19.         MemoryStream ms = new MemoryStream(bytes);
  20.         BinaryReader reader = new BinaryReader(ms);
  21.  
  22.         List<int> buttonMapping = new List<int>();
  23.  
  24.         while (ms.Position < ms.Length)
  25.         {
  26.             buttonMapping.Add(reader.ReadInt32());
  27.         }
  28.  
  29.        
  30.  
  31.         return buttonMapping.ToArray();
  32.  
  33.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top