Accessing Generic Dictionary #83
Unanswered
JulianWinter1124
asked this question in
Q&A
Replies: 1 comment 4 replies
-
What do you mean by "This is undefined! Doesnt work! Cannot call further methods"? Does it throw any error? Il2Cpp.perform(() => {
const SystemString = Il2Cpp.Image.corlib.classes["System.String"];
const SystemInt32 = Il2Cpp.Image.corlib.classes["System.Int32"];
const Dictionary = Il2Cpp.Image.corlib.classes["System.Collections.Generic.Dictionary<TKey,TValue>"].inflate(SystemString, SystemInt32);
const dict = Dictionary.new();
dict.methods.Add.invoke(Il2Cpp.String.from("hello"), 128);
dict.methods.Add.invoke(Il2Cpp.String.from("world"), 256);
const keys = dict.methods.get_Keys.invoke<Il2Cpp.Object>();
// method 1
const keysEnumerator = keys.methods.GetEnumerator.invoke<Il2Cpp.ValueType>().box();
while (keysEnumerator.methods.MoveNext.invoke<boolean>()) {
console.log(`> ${keysEnumerator.methods.get_Current.invoke<Il2Cpp.String>()}`);
}
keysEnumerator.methods.Dispose.invoke<void>();
// method 2
const count = keys.methods.get_Count.invoke<number>();
const array = Il2Cpp.Array.from(SystemString, new Array(count).fill(new Il2Cpp.String(NULL)));
keys.methods.CopyTo.invoke<void>(array, 0);
console.log(array);
}); |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I hope you dont mind me opening a new discussion but I had some difficulties iterating over a Dictionary while Generic Lists were no problem at all.
Let's say there is the following code:
and i hook the
DoWhatever
function with:Beta Was this translation helpful? Give feedback.
All reactions