diff --git a/ProjectFish/Source/ProjectFishEditor/Private/AssetActions/BagConfigAssetTypeAction.cpp b/ProjectFish/Source/ProjectFishEditor/Private/AssetActions/BagConfigAssetTypeAction.cpp new file mode 100644 index 0000000..61c9b2c --- /dev/null +++ b/ProjectFish/Source/ProjectFishEditor/Private/AssetActions/BagConfigAssetTypeAction.cpp @@ -0,0 +1,23 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "AssetActions/BagConfigAssetTypeAction.h" + +#include "ProjectFish/DataAsset/BagConfigAsset.h" + + +UClass* FBagConfigAssetTypeAction::GetSupportedClass() const +{ + return UBagConfigAsset::StaticClass(); +} + +void FBagConfigAssetTypeAction::OpenAssetEditor(const TArray& InObjects, + TSharedPtr EditWithinLevelEditor) +{ + //FAssetTypeActions_Base::OpenAssetEditor(InObjects, EditWithinLevelEditor); +} + +uint32 FBagConfigAssetTypeAction::GetCategories() +{ + return MyAssetCategory; +} diff --git a/ProjectFish/Source/ProjectFishEditor/Private/Factory/BagConfigFactory.cpp b/ProjectFish/Source/ProjectFishEditor/Private/Factory/BagConfigFactory.cpp new file mode 100644 index 0000000..283c1e9 --- /dev/null +++ b/ProjectFish/Source/ProjectFishEditor/Private/Factory/BagConfigFactory.cpp @@ -0,0 +1,24 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Factory/BagConfigFactory.h" + +#include "ProjectFish/DataAsset/BagConfigAsset.h" + +UBagConfigFactory::UBagConfigFactory() +{ + SupportedClass = UBagConfigAsset::StaticClass(); +} + +UObject* UBagConfigFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, + UObject* Context, FFeedbackContext* Warn) +{ + UBagConfigAsset* NewBagConfigAsset = NewObject(InParent, Class, Name, Flags | RF_Transactional); + + return NewBagConfigAsset; +} + +bool UBagConfigFactory::ShouldShowInNewMenu() const +{ + return true; +} diff --git a/ProjectFish/Source/ProjectFishEditor/Private/ProjectFishEditor.cpp b/ProjectFish/Source/ProjectFishEditor/Private/ProjectFishEditor.cpp index fcd7be8..4ae8b79 100644 --- a/ProjectFish/Source/ProjectFishEditor/Private/ProjectFishEditor.cpp +++ b/ProjectFish/Source/ProjectFishEditor/Private/ProjectFishEditor.cpp @@ -2,6 +2,7 @@ #include "AssetTypeActions_Base.h" #include "DataTableRowSelectorCustomization.h" +#include "AssetActions/BagConfigAssetTypeAction.h" #include "AssetActions/BagShapeAssetTypeAction.h" #include "AssetRegistry/AssetRegistryModule.h" #include "ProjectFish/DataAsset/BagShapeAsset.h" @@ -17,6 +18,8 @@ void FProjectFishEditorModule::StartupModule() //注册资源类型编辑器 RegisterAssetTypeActions(); + //注册资源缩略图 + RegisterThumbnailRenderers(); } void FProjectFishEditorModule::ShutdownModule() @@ -27,21 +30,28 @@ void FProjectFishEditorModule::ShutdownModule() } //注销资源类型编辑器 UnregisterAssetTypeActions(); + //注销缩略图 + UnregisterThumbnailRenderers(); } void FProjectFishEditorModule::RegisterAssetTypeActions() { FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked("AssetTools"); IAssetTools& AssetTools = AssetToolsModule.Get(); - //注册自定义的菜单 - EAssetTypeCategories::Type BoxShapeAssetCategory = AssetTools.RegisterAdvancedAssetCategory(FName(TEXT("Bag")), FText::FromString(TEXT("BagSystem"))); + //注册背包形状的菜单 + EAssetTypeCategories::Type BogShapeAssetCategory = AssetTools.RegisterAdvancedAssetCategory(FName(TEXT("BagShape")), FText::FromString(TEXT("BagSystem"))); //BagShape - TSharedRef BagShapeAction = MakeShareable(new FBagShapeAssetTypeAction(BoxShapeAssetCategory)); + TSharedRef BagShapeAction = MakeShareable(new FBagShapeAssetTypeAction(BogShapeAssetCategory)); AssetTools.RegisterAssetTypeActions(BagShapeAction); CreatedAssetTypeActions.Add(BagShapeAction); + //注册背包配置菜单 + //EAssetTypeCategories::Type BagConfigAssetCategory = AssetTools.RegisterAdvancedAssetCategory(FName(TEXT("BagConfig")), FText::FromString(TEXT("BagSystem"))); + TSharedRef BagConfigAction = MakeShareable(new FBagConfigAssetTypeAction(BogShapeAssetCategory)); + AssetTools.RegisterAssetTypeActions(BagConfigAction); + CreatedAssetTypeActions.Add(BagConfigAction); + - RegisterThumbnailRenderers(); } void FProjectFishEditorModule::UnregisterAssetTypeActions() @@ -56,8 +66,7 @@ void FProjectFishEditorModule::UnregisterAssetTypeActions() } } CreatedAssetTypeActions.Empty(); - - UnregisterThumbnailRenderers(); + } void FProjectFishEditorModule::RegisterThumbnailRenderers() diff --git a/ProjectFish/Source/ProjectFishEditor/ProjectFishEditor.Build.cs b/ProjectFish/Source/ProjectFishEditor/ProjectFishEditor.Build.cs index e8f38a1..0abec18 100644 --- a/ProjectFish/Source/ProjectFishEditor/ProjectFishEditor.Build.cs +++ b/ProjectFish/Source/ProjectFishEditor/ProjectFishEditor.Build.cs @@ -9,7 +9,7 @@ public class ProjectFishEditor : ModuleRules PublicDependencyModuleNames.AddRange( new string[] { - "Core", + "Core" } ); diff --git a/ProjectFish/Source/ProjectFishEditor/Public/AssetActions/BagConfigAssetTypeAction.h b/ProjectFish/Source/ProjectFishEditor/Public/AssetActions/BagConfigAssetTypeAction.h new file mode 100644 index 0000000..39e8da5 --- /dev/null +++ b/ProjectFish/Source/ProjectFishEditor/Public/AssetActions/BagConfigAssetTypeAction.h @@ -0,0 +1,28 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "AssetTypeActions_Base.h" + +/** + * + */ +class PROJECTFISHEDITOR_API FBagConfigAssetTypeAction: public FAssetTypeActions_Base +{ +public: + FBagConfigAssetTypeAction(EAssetTypeCategories::Type InAssetCategory) + { + MyAssetCategory = InAssetCategory; + } + virtual FText GetName() const override { return FText::FromString("Bag Config"); } + virtual FColor GetTypeColor() const override { return FColor(255, 196, 115); } + virtual UClass* GetSupportedClass() const override; + virtual void OpenAssetEditor(const TArray& InObjects, TSharedPtr EditWithinLevelEditor = TSharedPtr()) override; + virtual uint32 GetCategories() override; + virtual bool CanFilter() override { return true; } + virtual bool HasActions(const TArray& InObjects) const override { return false; } + +private: + EAssetTypeCategories::Type MyAssetCategory; +}; diff --git a/ProjectFish/Source/ProjectFishEditor/Public/Factory/BagConfigFactory.h b/ProjectFish/Source/ProjectFishEditor/Public/Factory/BagConfigFactory.h new file mode 100644 index 0000000..3148547 --- /dev/null +++ b/ProjectFish/Source/ProjectFishEditor/Public/Factory/BagConfigFactory.h @@ -0,0 +1,22 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Factories/Factory.h" +#include "BagConfigFactory.generated.h" + +/** + * + */ +UCLASS() +class PROJECTFISHEDITOR_API UBagConfigFactory : public UFactory +{ + GENERATED_BODY() +public: + UBagConfigFactory(); + + //interface + virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override; + virtual bool ShouldShowInNewMenu() const override; +};