diff --git a/unity/native_src/Src/CppObjectMapper.cpp b/unity/native_src/Src/CppObjectMapper.cpp
index 6a5d64b5c8..04590a6044 100644
--- a/unity/native_src/Src/CppObjectMapper.cpp
+++ b/unity/native_src/Src/CppObjectMapper.cpp
@@ -143,13 +143,16 @@ void FCppObjectMapper::CallbackDataGarbageCollected(const v8::WeakCallbackInfo
FCppObjectMapper::CreateFunction(v8::Local Context, pesapi_callback Callback, void* Data, pesapi_function_finalize Finalize)
{
+ auto Isolate = Context->GetIsolate();
auto CallbackData = new PesapiCallbackData {Callback, Data, this};
CallbackData->Finalize = Finalize;
- auto V8Data = v8::External::New(Context->GetIsolate(), &CallbackData->Data);
- auto Ret = v8::FunctionTemplate::New(Context->GetIsolate(), PesapiFunctionCallback, V8Data)->GetFunction(Context);
+ auto V8Data = v8::External::New(Isolate, &CallbackData->Data);
+ auto Template = v8::FunctionTemplate::New(Isolate, PesapiFunctionCallback, V8Data);
+ Template->Set(Isolate, "__do_not_cache", v8::ObjectTemplate::New(Isolate));
+ auto Ret = Template->GetFunction(Context);
if (!Ret.IsEmpty())
{
- CallbackData->JsFunction.Reset(Context->GetIsolate(), Ret.ToLocalChecked());
+ CallbackData->JsFunction.Reset(Isolate, Ret.ToLocalChecked());
CallbackData->JsFunction.SetWeak(
CallbackData, CallbackDataGarbageCollected, v8::WeakCallbackType::kInternalFields);
FunctionDatas.push_back(CallbackData);