@@ -262,6 +262,8 @@ void FUnrealEnginePythonModule::StartupModule()
262262 Py_SetPythonHome (home);
263263 }
264264
265+ TArray<FString> ImportModules;
266+
265267 FString IniValue;
266268 if (GConfig->GetString (UTF8_TO_TCHAR (" Python" ), UTF8_TO_TCHAR (" ProgramName" ), IniValue, GEngineIni))
267269 {
@@ -316,6 +318,12 @@ void FUnrealEnginePythonModule::StartupModule()
316318 ZipPath = FPaths::Combine (*PROJECT_CONTENT_DIR, *IniValue);
317319 }
318320
321+ if (GConfig->GetString (UTF8_TO_TCHAR (" Python" ), UTF8_TO_TCHAR (" ImportModules" ), IniValue, GEngineIni))
322+ {
323+ const TCHAR* separators[] = { TEXT (" " ), TEXT (" ;" ), TEXT (" ," ) };
324+ IniValue.ParseIntoArray (ImportModules, separators, 3 );
325+ }
326+
319327 FString ProjectScriptsPath = FPaths::Combine (*PROJECT_CONTENT_DIR, UTF8_TO_TCHAR (" Scripts" ));
320328 if (!FPaths::DirectoryExists (ProjectScriptsPath))
321329 {
@@ -480,6 +488,19 @@ void FUnrealEnginePythonModule::StartupModule()
480488#endif
481489 }
482490
491+
492+ for (FString ImportModule : ImportModules)
493+ {
494+ if (PyImport_ImportModule (TCHAR_TO_UTF8 (*ImportModule)))
495+ {
496+ UE_LOG (LogPython, Log, TEXT (" %s Python module successfully imported" ), *ImportModule);
497+ }
498+ else
499+ {
500+ unreal_engine_py_log_error ();
501+ }
502+ }
503+
483504 // release the GIL
484505 PyThreadState *UEPyGlobalState = PyEval_SaveThread ();
485506}
0 commit comments