class A : Il2CppSystem.Object { }
class B : A { }
class C : A { }
var list = new List<A>() { new A(), new B(), new C() };
In this case, when I try to get list[2].GetType(), I get typeof(A).
I was able to get actual type of it using code below
public static Type GetActualType(Il2CppSystem.Object obj)
{
var cpptype = obj.GetIl2CppType();
return Type.GetType(cpptype.AssemblyQualifiedName);
}
but I cannot cast object into type with cppobj.Cast<actualType>() because I cannot provide type variable into it. Is there any other way to cast il2cpp object into specific type variable in runtime?
For example,
In this case, when I try to get
list[2].GetType()
, I gettypeof(A)
. I was able to get actual type of it using code belowbut I cannot cast object into type with
cppobj.Cast<actualType>()
because I cannot provide type variable into it. Is there any other way to cast il2cpp object into specific type variable in runtime?