MCPcopy Create free account
hub / github.com/SpecialKO/SpecialK / SK_Unity_SetFixedDeltaTime

Function SK_Unity_SetFixedDeltaTime

src/plugins/unity.cpp:2034–2420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2032 WriteRelease (&timing_thread, 0);
2033
2034 return 0;
2035 }, L"[SK] Unity Timing Override");
2036 }
2037 }
2038}
2039
2040void
2041SK_Unity_SetFixedDeltaTime (float fixed_delta_time)
2042{
2043 fixed_delta_time_static = fixed_delta_time;
2044
2045 if (SK_mono_thread_attach != nullptr)
2046 {
2047 SK_Thread_CreateEx ([](LPVOID)->DWORD
2048 {
2049 AttachThread ();
2050
2051 SK_RunOnce (LoadMonoAssembly ("UnityEngine.CoreModule"));
2052 SK_RunOnce (LoadMonoAssembly ("UnityEngine"));
2053
2054 auto core_module_file = "UnityEngine.CoreModule";
2055 auto core_module = SK_mono_image_loaded (core_module_file);
2056 if (!core_module) { core_module_file = "UnityEngine";
2057 core_module = SK_mono_image_loaded (core_module_file);
2058 }
2059
2060 static auto klass = SK_mono_class_from_name (core_module, "UnityEngine", "Time");
2061
2062 set_fixedDeltaTime_mono = klass != nullptr ? SK_mono_class_get_method_from_name (klass, "set_fixedDeltaTime", 1) : nullptr;
2063 static MonoMethod* get_fixedDeltaTime = klass != nullptr ? SK_mono_class_get_method_from_name (klass, "get_fixedDeltaTime", 0) : nullptr;
2064
2065 static MonoMethod* set_timeScale = klass != nullptr ? SK_mono_class_get_method_from_name (klass, "set_timeScale", 1) : nullptr;
2066 static MonoMethod* get_timeScale = klass != nullptr ? SK_mono_class_get_method_from_name (klass, "get_timeScale", 0) : nullptr;
2067
2068 if (set_fixedDeltaTime_mono != nullptr &&
2069 set_timeScale != nullptr)
2070 {
2071 SK_RunOnce (
2072 void* pfnUnityEngine_Time_set_fixedDeltaTime = nullptr;
2073 void* pfnUnityEngine_Time_set_timeScale = nullptr;
2074
2075 pfnUnityEngine_Time_set_fixedDeltaTime =
2076 CompileMethod ("UnityEngine", "Time", "set_fixedDeltaTime", 1, core_module_file);
2077 pfnUnityEngine_Time_set_timeScale =
2078 CompileMethod ("UnityEngine", "Time", "set_timeScale", 1, core_module_file);
2079
2080/*
2081#ifdef SK_UNITY_SET_FIXEDDELTATIME_HOOK_DOES_NOT_KILL_PERFORMANCE_IN_PRINCE_OF_PERSIA
2082 if (pfnUnityEngine_Time_set_fixedDeltaTime != nullptr)
2083 {
2084 SK_CreateFuncHook ( L"UnityEngine.Time.set_fixedDeltaTime",
2085 pfnUnityEngine_Time_set_fixedDeltaTime,
2086 UnityEngine_Time_set_fixedDeltaTime_Detour,
2087 static_cast_p2p <void> (&UnityEngine_Time_set_fixedDeltaTime_Original) );
2088 }
2089#endif
2090*/
2091

Callers 3

SK_Unity_PlugInCfgFunction · 0.85
SK_Unity_EndFrameFunction · 0.85

Calls 14

SK_Thread_CreateExFunction · 0.85
SK_RunOnceFunction · 0.85
SK_CreateFuncHookFunction · 0.85
SK_QueueEnableHookFunction · 0.85
SK_ApplyQueuedHooksFunction · 0.85
SK_Thread_CloseSelfFunction · 0.85
get_imageMethod · 0.80
get_methodMethod · 0.80
AttachThreadFunction · 0.70
LoadMonoAssemblyFunction · 0.70
CompileMethodFunction · 0.70

Tested by

no test coverage detected