diff --git a/unity/native_src_il2cpp/Src/Puerts.cpp b/unity/native_src_il2cpp/Src/Puerts.cpp index c8f905fc98..bfe541b0d3 100644 --- a/unity/native_src_il2cpp/Src/Puerts.cpp +++ b/unity/native_src_il2cpp/Src/Puerts.cpp @@ -706,19 +706,20 @@ struct JSEnv #endif v8::V8::SetFlagsFromString(Flags.c_str(), static_cast(Flags.size())); - MainIsolate = BackendEnv.CreateIsolate(nullptr); + BackendEnv.Initialize(); + MainIsolate = BackendEnv.MainIsolate; auto Isolate = MainIsolate; v8::Isolate::Scope Isolatescope(Isolate); v8::HandleScope HandleScope(Isolate); - v8::Local Context = v8::Context::New(Isolate); + v8::Local Context = BackendEnv.MainContext.Get(Isolate);; v8::Context::Scope ContextScope(Context); MainContext.Reset(Isolate, Context); - BackendEnv.InitInject(MainIsolate, Context); + BackendEnv.InitInject(); CppObjectMapper.Initialize(Isolate, Context); Isolate->SetData(MAPPER_ISOLATE_DATA_POS, static_cast(&CppObjectMapper)); Isolate->SetData(BACKENDENV_DATA_POS, &BackendEnv); @@ -784,7 +785,7 @@ struct JSEnv } MainContext.Reset(); - BackendEnv.FreeIsolate(); + BackendEnv.UnInitialize(); } v8::Isolate* MainIsolate;