添加背包配置资源列表项
This commit is contained in:
parent
2a4643b85b
commit
5713ef088b
@ -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<UObject*>& InObjects,
|
||||
TSharedPtr<class IToolkitHost> EditWithinLevelEditor)
|
||||
{
|
||||
//FAssetTypeActions_Base::OpenAssetEditor(InObjects, EditWithinLevelEditor);
|
||||
}
|
||||
|
||||
uint32 FBagConfigAssetTypeAction::GetCategories()
|
||||
{
|
||||
return MyAssetCategory;
|
||||
}
|
||||
@ -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<UBagConfigAsset>(InParent, Class, Name, Flags | RF_Transactional);
|
||||
|
||||
return NewBagConfigAsset;
|
||||
}
|
||||
|
||||
bool UBagConfigFactory::ShouldShowInNewMenu() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -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<FAssetToolsModule>("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<FAssetTypeActions_Base> BagShapeAction = MakeShareable(new FBagShapeAssetTypeAction(BoxShapeAssetCategory));
|
||||
TSharedRef<FAssetTypeActions_Base> BagShapeAction = MakeShareable(new FBagShapeAssetTypeAction(BogShapeAssetCategory));
|
||||
AssetTools.RegisterAssetTypeActions(BagShapeAction);
|
||||
CreatedAssetTypeActions.Add(BagShapeAction);
|
||||
|
||||
//注册背包配置菜单
|
||||
//EAssetTypeCategories::Type BagConfigAssetCategory = AssetTools.RegisterAdvancedAssetCategory(FName(TEXT("BagConfig")), FText::FromString(TEXT("BagSystem")));
|
||||
TSharedRef<FAssetTypeActions_Base> 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()
|
||||
|
||||
@ -9,7 +9,7 @@ public class ProjectFishEditor : ModuleRules
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
"Core"
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@ -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<UObject*>& InObjects, TSharedPtr<class IToolkitHost> EditWithinLevelEditor = TSharedPtr<IToolkitHost>()) override;
|
||||
virtual uint32 GetCategories() override;
|
||||
virtual bool CanFilter() override { return true; }
|
||||
virtual bool HasActions(const TArray<UObject*>& InObjects) const override { return false; }
|
||||
|
||||
private:
|
||||
EAssetTypeCategories::Type MyAssetCategory;
|
||||
};
|
||||
@ -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;
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user