-
Notifications
You must be signed in to change notification settings - Fork 1
/
Il2CppString.cs
35 lines (26 loc) · 929 Bytes
/
Il2CppString.cs
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
using System;
using Unity.Collections.LowLevel.Unsafe;
namespace IL2CPPUtility {
public unsafe struct Il2CppStringHandle {
public Il2CppString* Value;
public Il2CppStringHandle(Il2CppString* value) {
Value = value;
}
public Il2CppStringHandle(string str) {
Value = (Il2CppString*) UnsafeUtility.As<string, IntPtr>(ref str);
}
public ref string CSString {
get {
var p = (IntPtr*) UnsafeUtility.AddressOf(ref this);
return ref UnsafeUtility.As<IntPtr, string>(ref p[0]);
}
}
public static implicit operator Il2CppStringHandle(string str) => new Il2CppStringHandle(str);
public override string ToString() => CSString;
}
public unsafe struct Il2CppString {
public Il2CppObject Object;
public int length;
public char* chars;
}
}