完善BagShape Editor
This commit is contained in:
parent
bc36d855ac
commit
445f21fe7b
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "AssetActions/BagShapeAssetTypeAction.h"
|
#include "AssetActions/BagShapeAssetTypeAction.h"
|
||||||
|
|
||||||
|
#include "AssetEditor/BagShapeAssetEditor.h"
|
||||||
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
||||||
|
|
||||||
|
|
||||||
@ -14,7 +15,16 @@ UClass* FBagShapeAssetTypeAction::GetSupportedClass() const
|
|||||||
void FBagShapeAssetTypeAction::OpenAssetEditor(const TArray<UObject*>& InObjects,
|
void FBagShapeAssetTypeAction::OpenAssetEditor(const TArray<UObject*>& InObjects,
|
||||||
TSharedPtr<IToolkitHost> EditWithinLevelEditor)
|
TSharedPtr<IToolkitHost> EditWithinLevelEditor)
|
||||||
{
|
{
|
||||||
FAssetTypeActions_Base::OpenAssetEditor(InObjects, EditWithinLevelEditor);
|
EToolkitMode::Type Mode = EditWithinLevelEditor.IsValid() ? EToolkitMode::WorldCentric : EToolkitMode::Standalone;
|
||||||
|
|
||||||
|
for (auto ObjIt = InObjects.CreateConstIterator(); ObjIt; ++ObjIt)
|
||||||
|
{
|
||||||
|
if (UBagShapeAsset* BagShapeAsset = Cast<UBagShapeAsset>(*ObjIt))
|
||||||
|
{
|
||||||
|
TSharedRef<FBagShapeAssetEditor> EditorToolkit = MakeShareable(new FBagShapeAssetEditor());
|
||||||
|
EditorToolkit->Initialize(Mode, EditWithinLevelEditor, BagShapeAsset);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,74 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "AssetEditor/BagShapeAssetEditor.h"
|
||||||
|
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
||||||
|
#include "Widgets/BagShapeEditorWidget.h"
|
||||||
|
|
||||||
|
const FName FBagShapeAssetEditor::BagShapeEditorTabId(TEXT("BagShapeEditor"));
|
||||||
|
|
||||||
|
void FBagShapeAssetEditor::Initialize(const EToolkitMode::Type Mode,
|
||||||
|
const TSharedPtr<class IToolkitHost>& InitToolkitHost, UBagShapeAsset* InBagShapeAsset)
|
||||||
|
{
|
||||||
|
BagShapeAsset = InBagShapeAsset;
|
||||||
|
|
||||||
|
const TSharedRef<FTabManager::FLayout> StandaloneDefaultLayout = FTabManager::NewLayout("Standalone_BagShapeAssetEditor_Layout_v1")
|
||||||
|
->AddArea
|
||||||
|
(
|
||||||
|
FTabManager::NewPrimaryArea()->SetOrientation(Orient_Vertical)
|
||||||
|
->Split
|
||||||
|
(
|
||||||
|
FTabManager::NewStack()
|
||||||
|
->SetSizeCoefficient(1.0f)
|
||||||
|
->AddTab(BagShapeEditorTabId, ETabState::OpenedTab)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
FAssetEditorToolkit::InitAssetEditor(Mode, InitToolkitHost, TEXT("BagShapeAssetEditorApp"), StandaloneDefaultLayout, true, true, InBagShapeAsset);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FName FBagShapeAssetEditor::GetToolkitFName() const
|
||||||
|
{
|
||||||
|
return FName("BagShapeEditor");
|
||||||
|
}
|
||||||
|
|
||||||
|
FText FBagShapeAssetEditor::GetBaseToolkitName() const
|
||||||
|
{
|
||||||
|
return FText::FromString("Base BagShapeEditor");
|
||||||
|
}
|
||||||
|
|
||||||
|
FString FBagShapeAssetEditor::GetWorldCentricTabPrefix() const
|
||||||
|
{
|
||||||
|
return TEXT("ShapeTab");
|
||||||
|
}
|
||||||
|
|
||||||
|
FLinearColor FBagShapeAssetEditor::GetWorldCentricTabColorScale() const
|
||||||
|
{
|
||||||
|
//return FLinearColor::White;
|
||||||
|
return FLinearColor(1.f, 0.8f, 0.45f, 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FBagShapeAssetEditor::RegisterTabSpawners(const TSharedRef<FTabManager>& tabManager)
|
||||||
|
{
|
||||||
|
WorkspaceMenuCategory = tabManager->AddLocalWorkspaceMenuCategory( FText::FromString("BagShape"));
|
||||||
|
|
||||||
|
tabManager->RegisterTabSpawner(BagShapeEditorTabId, FOnSpawnTab::CreateSP(this, &FBagShapeAssetEditor::SpawnBagShapeEditorTab))
|
||||||
|
.SetDisplayName( FText::FromString("BagShapeEditor"))
|
||||||
|
.SetGroup(WorkspaceMenuCategory.ToSharedRef());
|
||||||
|
}
|
||||||
|
|
||||||
|
void FBagShapeAssetEditor::UnregisterTabSpawners(const TSharedRef<FTabManager>& tabManager)
|
||||||
|
{
|
||||||
|
tabManager->UnregisterTabSpawner(BagShapeEditorTabId);
|
||||||
|
}
|
||||||
|
|
||||||
|
TSharedRef<SDockTab> FBagShapeAssetEditor::SpawnBagShapeEditorTab(const FSpawnTabArgs& Args)
|
||||||
|
{
|
||||||
|
return SNew(SDockTab)
|
||||||
|
.TabRole(ETabRole::PanelTab)
|
||||||
|
[
|
||||||
|
SNew(SBagShapeEditorWidget)
|
||||||
|
.BagShapeAsset(BagShapeAsset)
|
||||||
|
];
|
||||||
|
}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "Widgets/BagShapeEditorWidget.h"
|
||||||
|
|
||||||
|
|
||||||
|
void SBagShapeEditorWidget::Construct(const FArguments& InArgs)
|
||||||
|
{
|
||||||
|
BagShapeAsset = InArgs._BagShapeAsset;
|
||||||
|
}
|
||||||
@ -19,7 +19,8 @@ public:
|
|||||||
virtual FColor GetTypeColor() const override { return FColor(129, 196, 115); }
|
virtual FColor GetTypeColor() const override { return FColor(129, 196, 115); }
|
||||||
virtual UClass* GetSupportedClass() const override;
|
virtual UClass* GetSupportedClass() const override;
|
||||||
virtual void OpenAssetEditor(const TArray<UObject*>& InObjects, TSharedPtr<IToolkitHost> EditWithinLevelEditor = TSharedPtr<IToolkitHost>()) override;
|
virtual void OpenAssetEditor(const TArray<UObject*>& InObjects, TSharedPtr<IToolkitHost> EditWithinLevelEditor = TSharedPtr<IToolkitHost>()) override;
|
||||||
virtual bool HasActions(const TArray<UObject*>& InObjects) const override {return true;}
|
//是否使用自定义的Action菜单
|
||||||
|
virtual bool HasActions(const TArray<UObject*>& InObjects) const override {return false;}
|
||||||
virtual uint32 GetCategories() override; ;
|
virtual uint32 GetCategories() override; ;
|
||||||
virtual void GetActions(const TArray<UObject*>& InObjects, struct FToolMenuSection& Section) override;
|
virtual void GetActions(const TArray<UObject*>& InObjects, struct FToolMenuSection& Section) override;
|
||||||
virtual bool CanFilter() override {return true;}
|
virtual bool CanFilter() override {return true;}
|
||||||
|
|||||||
@ -0,0 +1,33 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "Toolkits/AssetEditorToolkit.h"
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class PROJECTFISHEDITOR_API FBagShapeAssetEditor: public FAssetEditorToolkit
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void Initialize(const EToolkitMode::Type Mode, const TSharedPtr<class IToolkitHost>& InitToolkitHost, class UBagShapeAsset* InBagShapeAsset);
|
||||||
|
|
||||||
|
// IAssetEditorInstance interface
|
||||||
|
virtual FName GetToolkitFName() const override;
|
||||||
|
virtual FText GetBaseToolkitName() const override;
|
||||||
|
virtual FString GetWorldCentricTabPrefix() const override;
|
||||||
|
virtual FLinearColor GetWorldCentricTabColorScale() const override;
|
||||||
|
|
||||||
|
// FAssetEditorToolkit interface
|
||||||
|
virtual void RegisterTabSpawners(const TSharedRef<FTabManager>& TabManager) override;
|
||||||
|
virtual void UnregisterTabSpawners(const TSharedRef<FTabManager>& TabManager) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
TSharedRef<SDockTab> SpawnBagShapeEditorTab(const FSpawnTabArgs& Args);
|
||||||
|
|
||||||
|
class UBagShapeAsset* BagShapeAsset;
|
||||||
|
/** Tab IDs */
|
||||||
|
static const FName BagShapeEditorTabId;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class PROJECTFISHEDITOR_API SBagShapeEditorWidget: public SCompoundWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SLATE_BEGIN_ARGS(SBagShapeEditorWidget) {}
|
||||||
|
SLATE_ARGUMENT(UBagShapeAsset*, BagShapeAsset)
|
||||||
|
SLATE_END_ARGS()
|
||||||
|
void Construct(const FArguments& InArgs);
|
||||||
|
|
||||||
|
private:
|
||||||
|
TWeakObjectPtr<class UBagShapeAsset> BagShapeAsset;
|
||||||
|
};
|
||||||
Loading…
x
Reference in New Issue
Block a user