// Copyright 2016 Mookie. All Rights Reserved. #include "EasyBallisticsEditor.h" #include "AssetToolsModule.h" #include "PropertyEditorModule.h" #include "EBMaterialResponseMapFactory.h" #include "EBBulletPropertiesFactory.h" #include "EBBulletActorFactory.h" #include "EBBarrelComponentFactory.h" #include "EBMathematicalBallisticsFactory.h" #include "EBPhysicalMaterialCustomization.h" #include "PhysicalMaterials/PhysicalMaterial.h" #define LOCTEXT_NAMESPACE "FEasyBallisticsEditorModule" EAssetTypeCategories::Type FEasyBallisticsEditorModule::BallisticsAssetCategory; void FEasyBallisticsEditorModule::StartupModule() { // Register asset factories IAssetTools& AssetTools = FModuleManager::LoadModuleChecked("AssetTools").Get(); // Register the Ballistics category BallisticsAssetCategory = AssetTools.RegisterAdvancedAssetCategory(FName(TEXT("Ballistics")), LOCTEXT("BallisticsCategory", "Ballistics")); // Store references to our asset type actions for cleanup RegisteredAssetTypeActions.Empty(); // Register Material Response Map factory { TSharedRef MaterialResponseMapActions = MakeShareable(new FEBMaterialResponseMapFactory()); AssetTools.RegisterAssetTypeActions(MaterialResponseMapActions); RegisteredAssetTypeActions.Add(MaterialResponseMapActions); } // Register Bullet Properties Asset factory { TSharedRef BulletPropertiesActions = MakeShareable(new FEBBulletPropertiesAssetFactory()); AssetTools.RegisterAssetTypeActions(BulletPropertiesActions); RegisteredAssetTypeActions.Add(BulletPropertiesActions); } // Register Physical Material customization FPropertyEditorModule& PropertyModule = FModuleManager::LoadModuleChecked("PropertyEditor"); PropertyModule.RegisterCustomClassLayout( UPhysicalMaterial::StaticClass()->GetFName(), FOnGetDetailCustomizationInstance::CreateStatic(&FEBPhysicalMaterialCustomization::MakeInstance) ); } void FEasyBallisticsEditorModule::ShutdownModule() { // Unregister Physical Material customization if (FModuleManager::Get().IsModuleLoaded("PropertyEditor")) { FPropertyEditorModule& PropertyModule = FModuleManager::GetModuleChecked("PropertyEditor"); PropertyModule.UnregisterCustomClassLayout(UPhysicalMaterial::StaticClass()->GetFName()); } // Unregister asset type actions if (FModuleManager::Get().IsModuleLoaded("AssetTools")) { IAssetTools& AssetTools = FModuleManager::GetModuleChecked("AssetTools").Get(); for (auto& AssetTypeAction : RegisteredAssetTypeActions) { if (AssetTypeAction.IsValid()) { AssetTools.UnregisterAssetTypeActions(AssetTypeAction.ToSharedRef()); } } } RegisteredAssetTypeActions.Empty(); } #undef LOCTEXT_NAMESPACE IMPLEMENT_MODULE(FEasyBallisticsEditorModule, EasyBallisticsEditor)