public static void Call() { IntPtr classAddress = NativeReflection.GetClass("/Script/UnrealEngine_Runtime.MyClass"); StringTest_FunctionAddress = NativeReflection.GetFunction(classAddress, "MyTestFunc2"); StringTest_ParamsSize = NativeReflection.GetFunctionParamsSize(StringTest_FunctionAddress); StringTest_inVal_Offset = NativeReflection.GetPropertyOffset(StringTest_FunctionAddress, "inVal"); StringTest_stringTest_Offset = NativeReflection.GetPropertyOffset(StringTest_FunctionAddress, "stringTest"); StringTest_ParamResult_Offset = NativeReflection.GetPropertyOffset(StringTest_FunctionAddress, "__return"); UMyClass myClass = UObject.NewObject <UMyClass>(); string refVal = "inref"; string arg = "hello world"; unsafe { byte * ParamsBufferAllocation = stackalloc byte[StringTest_ParamsSize]; IntPtr ParamsBuffer = new IntPtr(ParamsBufferAllocation); FStringMarshaler.ToNative(IntPtr.Add(ParamsBuffer, StringTest_inVal_Offset), refVal); //FStringMarshaler.ToNative(IntPtr.Add(ParamsBuffer, StringTest_stringTest_Offset), arg); NativeReflection.InvokeFunction(myClass.Address, StringTest_FunctionAddress, ParamsBuffer, StringTest_ParamsSize); refVal = FStringMarshaler.FromNative(IntPtr.Add(ParamsBuffer, StringTest_inVal_Offset)); arg = FStringMarshaler.FromNative(IntPtr.Add(ParamsBuffer, StringTest_stringTest_Offset)); string toReturn = FStringMarshaler.FromNative(IntPtr.Add(ParamsBuffer, StringTest_ParamResult_Offset)); NativeReflection.InvokeFunction_DestroyAll(StringTest_FunctionAddress, ParamsBuffer); } }
static void LoadNativeType() { //if (NativeReflection.CachedTypeInfo.Enabled) //{ // NativeReflection.CachedTypeInfo typeInfo = NativeReflection.CachedTypeInfo.BuildFunction("/Script/USharp.SomeDelegate__DelegateSignature"); // SomeDelegate__DelegateSignature_FunctionAddress = typeInfo.Address; // SomeDelegate__DelegateSignature_ParamsSize = typeInfo.Size; // SomeDelegate__DelegateSignature_IsValid = typeInfo.Exists; // typeInfo.LogIsValid(SomeDelegate__DelegateSignature_IsValid); //} //else { SomeDelegate__DelegateSignature_FunctionAddress = NativeReflection.GetFunction("/Script/USharp.SomeDelegate__DelegateSignature"); SomeDelegate__DelegateSignature_ParamsSize = NativeReflection.GetFunctionParamsSize(SomeDelegate__DelegateSignature_FunctionAddress); SomeDelegate__DelegateSignature_IsValid = SomeDelegate__DelegateSignature_FunctionAddress != IntPtr.Zero; NativeReflection.LogFunctionIsValid("/Script/USharp.SomeDelegate__DelegateSignature", SomeDelegate__DelegateSignature_IsValid); } }
static void LoadNativeType() { //if (NativeReflection.CachedTypeInfo.Enabled) //{ // NativeReflection.CachedTypeInfo typeInfo = NativeReflection.CachedTypeInfo.BuildFunction("/Script/USharp.DelegateRefTest__DelegateSignature"); // DelegateRefTest__DelegateSignature_FunctionAddress = typeInfo.Address; // DelegateRefTest__DelegateSignature_ParamsSize = typeInfo.Size; // DelegateRefTest__DelegateSignature_SomeArgument_IsValid = typeInfo.GetPropertyRefOffsetAndValidate("SomeArgument", ref DelegateRefTest__DelegateSignature_SomeArgument_PropertyAddress, out DelegateRefTest__DelegateSignature_SomeArgument_Offset, Classes.UIntProperty); // DelegateRefTest__DelegateSignature_IsValid = typeInfo.Exists && DelegateRefTest__DelegateSignature_SomeArgument_IsValid; // typeInfo.LogIsValid(DelegateRefTest__DelegateSignature_IsValid); //} //else { DelegateRefTest__DelegateSignature_FunctionAddress = NativeReflection.GetFunction("/Script/USharp.DelegateRefTest__DelegateSignature"); DelegateRefTest__DelegateSignature_ParamsSize = NativeReflection.GetFunctionParamsSize(DelegateRefTest__DelegateSignature_FunctionAddress); NativeReflectionCached.GetPropertyRef(ref DelegateRefTest__DelegateSignature_SomeArgument_PropertyAddress, DelegateRefTest__DelegateSignature_FunctionAddress, "SomeArgument"); DelegateRefTest__DelegateSignature_SomeArgument_Offset = NativeReflectionCached.GetPropertyOffset(DelegateRefTest__DelegateSignature_FunctionAddress, "SomeArgument"); DelegateRefTest__DelegateSignature_SomeArgument_IsValid = NativeReflectionCached.ValidatePropertyClass(DelegateRefTest__DelegateSignature_FunctionAddress, "SomeArgument", Classes.UIntProperty); DelegateRefTest__DelegateSignature_IsValid = DelegateRefTest__DelegateSignature_FunctionAddress != IntPtr.Zero && DelegateRefTest__DelegateSignature_SomeArgument_IsValid; NativeReflection.LogFunctionIsValid("/Script/USharp.DelegateRefTest__DelegateSignature", DelegateRefTest__DelegateSignature_IsValid); } }
public static void Call2() { IntPtr classAddress = NativeReflection.GetClass("/Script/UnrealEngine_Runtime.MyClass"); Test2_FunctionAddress = NativeReflection.GetFunction(classAddress, "MyTestFunc3"); Test2_ParamsSize = NativeReflection.GetFunctionParamsSize(Test2_FunctionAddress); Test2_Param1_Offset = NativeReflection.GetPropertyOffset(Test2_FunctionAddress, "myStruct"); UMyClass myClass = UObject.NewObject <UMyClass>(); FMyStructCustomCtor val = StructDefault <FMyStructCustomCtor> .Value; unsafe { byte * ParamsBufferAllocation = stackalloc byte[Test2_ParamsSize]; IntPtr ParamsBuffer = new IntPtr(ParamsBufferAllocation); FMyStructCustomCtor.ToNative(IntPtr.Add(ParamsBuffer, Test2_Param1_Offset), val); NativeReflection.InvokeFunction(myClass.Address, Test2_FunctionAddress, ParamsBuffer, Test2_ParamsSize); NativeReflection.InvokeFunction_DestroyAll(Test2_FunctionAddress, ParamsBuffer); } }