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