54 const FString ContentDir = FPaths::ConvertRelativePathToFull(FPaths::ProjectContentDir());
58 const TCHAR* ExternalFolderNames[] = { TEXT(
"__ExternalActors__"), TEXT(
"__ExternalObjects__") };
60 TArray<FString> ContentRoots;
61 IFileManager::Get().FindFiles(ContentRoots, *(ContentDir / TEXT(
"*")),
false,
true);
63 for (
const FString& Root : ContentRoots)
65 for (
const TCHAR* FolderName : ExternalFolderNames)
67 const FString BundleFolder = ContentDir / Root / FolderName;
68 if (!FPaths::DirectoryExists(BundleFolder))
78 TArray<FString> Inner;
79 IFileManager::Get().FindFiles(Inner, *(BundleFolder / TEXT(
"*")),
false,
true);
80 for (
const FString& InnerName : Inner)
82 const FString RootPath = FString::Printf(
83 TEXT(
"/Game/%s/%s/"), FolderName, *InnerName);
84 const FString ContentPath = BundleFolder / InnerName / TEXT(
"");
88 FPackageName::UnRegisterMountPoint(RootPath, ContentPath);
89 FPackageName::RegisterMountPoint(RootPath, ContentPath);
90 UE_LOG(LogCarla, Log, TEXT(
"Mounted external package root %s -> %s"),
91 *RootPath, *ContentPath);
107 if (!GIsEditor || IsRunningCommandlet())
111 const FString PacksDir = FPaths::ConvertRelativePathToFull(FPaths::ProjectPluginsDir() / TEXT(
"Packs"));
112 TArray<FString> PackDirs;
113 IFileManager::Get().FindFiles(PackDirs, *(PacksDir / TEXT(
"*")),
false,
true);
115 IPluginManager& PluginManager = IPluginManager::Get();
116 for (
const FString& PackName : PackDirs)
118 const FString PluginFile = PacksDir / PackName / (PackName + TEXT(
".uplugin"));
119 if (!FPaths::FileExists(PluginFile))
123 TSharedPtr<IPlugin> Plugin = PluginManager.FindPlugin(PackName);
124 if (!Plugin.IsValid())
127 if (!PluginManager.AddToPluginsList(PluginFile, &FailReason))
129 UE_LOG(LogCarla, Warning, TEXT(
"Content pack plugin '%s' not registered: %s"),
130 *PluginFile, *FailReason.ToString());
133 Plugin = PluginManager.FindPlugin(PackName);
135 if (!Plugin.IsValid() || Plugin->IsMounted())
139 if (!Plugin->GetDescriptor().bExplicitlyLoaded)
144 if (PluginManager.MountExplicitlyLoadedPlugin(PackName))
146 UE_LOG(LogCarla, Log, TEXT(
"Content pack plugin '%s' mounted for the editor/cooker (%s)"),
147 *PackName, *PluginFile);
151 UE_LOG(LogCarla, Warning, TEXT(
"Content pack plugin '%s' could not be mounted (%s)"),
152 *PackName, *PluginFile);
163 if (AllShaderSourceDirectoryMappings().Contains(TEXT(
"/Plugin/Carla")))
166 const TSharedPtr<IPlugin> Plugin = IPluginManager::Get().FindPlugin(TEXT(
"Carla"));
167 if (!Plugin.IsValid())
169 UE_LOG(LogCarla, Error,
170 TEXT(
"AddShaderSearchPaths: Carla plugin not found; shaders will be unavailable."));
174 const FString ShadersDirectoryPath = FPaths::ConvertRelativePathToFull(
175 FPaths::Combine(Plugin->GetBaseDir(), TEXT(
"Shaders")));
176 if (!FPaths::DirectoryExists(ShadersDirectoryPath))
178 UE_LOG(LogCarla, Error,
179 TEXT(
"AddShaderSearchPaths: shader directory '%s' does not exist; shaders will be unavailable."),
180 *ShadersDirectoryPath);
184 UE_LOG(LogCarla, Log, TEXT(
"Carla shader directory: %s"), *ShadersDirectoryPath);
185 AddShaderSourceDirectoryMapping(TEXT(
"/Plugin/Carla"), ShadersDirectoryPath);
190 #if defined(WITH_CHRONO) && PLATFORM_WINDOWS
191 const FString BaseDir = FPaths::Combine(*FPaths::ProjectPluginsDir(), TEXT(
"Carla"));
192 const FString DllDir = FPaths::Combine(*BaseDir, TEXT(
"CarlaDependencies"), TEXT(
"dll"));
193 FString ChronoEngineDll = FPaths::Combine(*DllDir, TEXT(
"ChronoEngine.dll"));
194 FString ChronoVehicleDll = FPaths::Combine(*DllDir, TEXT(
"ChronoEngine_vehicle.dll"));
195 FString ChronoModelsDll = FPaths::Combine(*DllDir, TEXT(
"ChronoModels_vehicle.dll"));
196 FString ChronoRobotDll = FPaths::Combine(*DllDir, TEXT(
"ChronoModels_robot.dll"));
197 UE_LOG(LogCarla, Log, TEXT(
"Loading Dlls from: %s"), *DllDir);
198 auto ChronoEngineHandle = FPlatformProcess::GetDllHandle(*ChronoEngineDll);
199 if (!ChronoEngineHandle)
201 UE_LOG(LogCarla, Warning, TEXT(
"Error: ChronoEngine.dll could not be loaded"));
203 auto ChronoVehicleHandle = FPlatformProcess::GetDllHandle(*ChronoVehicleDll);
204 if (!ChronoVehicleHandle)
206 UE_LOG(LogCarla, Warning, TEXT(
"Error: ChronoEngine_vehicle.dll could not be loaded"));
208 auto ChronoModelsHandle = FPlatformProcess::GetDllHandle(*ChronoModelsDll);
209 if (!ChronoModelsHandle)
211 UE_LOG(LogCarla, Warning, TEXT(
"Error: ChronoModels_vehicle.dll could not be loaded"));
213 auto ChronoRobotHandle = FPlatformProcess::GetDllHandle(*ChronoRobotDll);
214 if (!ChronoRobotHandle)
216 UE_LOG(LogCarla, Warning, TEXT(
"Error: ChronoModels_robot.dll could not be loaded"));
240 if (ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>(
"Settings"))
243 ISettingsContainerPtr SettingsContainer = SettingsModule->GetContainer(
"Project");
245 SettingsContainer->DescribeCategory(
"CARLASettings",
246 LOCTEXT(
"RuntimeWDCategoryName",
"CARLA Settings"),
247 LOCTEXT(
"RuntimeWDCategoryDescription",
"CARLA plugin settings"));
250 ISettingsSectionPtr SettingsSection = SettingsModule->RegisterSettings(
"Project",
"CARLASettings",
"General",
251 LOCTEXT(
"RuntimeGeneralSettingsName",
"General"),
252 LOCTEXT(
"RuntimeGeneralSettingsDescription",
"General configuration for the CARLA plugin"),
253 GetMutableDefault<UCarlaSettings>()
258 if (SettingsSection.IsValid())
309 UE_LOG(LogCarla, Fatal, TEXT(
"Exception thrown: %s"), UTF8_TO_TCHAR(e.what()));