源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 rivejä
1.3 KiB

4 viikkoa sitten
  1. using System;
  2. using UnityEditor.MemoryProfiler;
  3. using UnityEngine;
  4. namespace MemoryProfilerWindow
  5. {
  6. internal struct BytesAndOffset
  7. {
  8. public byte[] bytes;
  9. public int offset;
  10. public int pointerSize;
  11. public bool IsValid { get { return bytes != null; }}
  12. public UInt64 ReadPointer()
  13. {
  14. if (pointerSize == 4)
  15. return BitConverter.ToUInt32(bytes, offset);
  16. if (pointerSize == 8)
  17. return BitConverter.ToUInt64(bytes, offset);
  18. throw new ArgumentException("Unexpected pointersize: " + pointerSize);
  19. }
  20. public Int32 ReadInt32()
  21. {
  22. return BitConverter.ToInt32(bytes, offset);
  23. }
  24. public Int64 ReadInt64()
  25. {
  26. return BitConverter.ToInt64(bytes, offset);
  27. }
  28. public BytesAndOffset Add(int add)
  29. {
  30. return new BytesAndOffset() {bytes = bytes, offset = offset + add, pointerSize = pointerSize};
  31. }
  32. public void WritePointer(UInt64 value)
  33. {
  34. for (int i = 0; i < pointerSize; i++)
  35. {
  36. bytes[i + offset] = (byte)value;
  37. value >>= 8;
  38. }
  39. }
  40. public BytesAndOffset NextPointer()
  41. {
  42. return Add(pointerSize);
  43. }
  44. }
  45. }