RemoteCommand.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.Text;
  3. using UnityEngine;
  4. namespace YooAsset
  5. {
  6. internal enum ERemoteCommand
  7. {
  8. /// <summary>
  9. /// 采样一次
  10. /// </summary>
  11. SampleOnce = 0,
  12. /// <summary>
  13. /// 自动采集
  14. /// </summary>
  15. SampleAuto = 1,
  16. }
  17. [Serializable]
  18. internal class RemoteCommand
  19. {
  20. /// <summary>
  21. /// 命令类型
  22. /// </summary>
  23. public int CommandType;
  24. /// <summary>
  25. /// 命令附加参数
  26. /// </summary>
  27. public string CommandParam;
  28. /// <summary>
  29. /// 序列化
  30. /// </summary>
  31. public static byte[] Serialize(RemoteCommand command)
  32. {
  33. return Encoding.UTF8.GetBytes(JsonUtility.ToJson(command));
  34. }
  35. /// <summary>
  36. /// 反序列化
  37. /// </summary>
  38. public static RemoteCommand Deserialize(byte[] data)
  39. {
  40. return JsonUtility.FromJson<RemoteCommand>(Encoding.UTF8.GetString(data));
  41. }
  42. }
  43. }