From c8a551888d4571c7ae29c573a922ea23afd46269 Mon Sep 17 00:00:00 2001 From: 997146918 <997146918@qq.com> Date: Fri, 29 Aug 2025 17:38:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=B3=E9=94=AE=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E5=88=9B=E5=BB=BABoxShape=20=E8=B5=84=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Private/Factory/BagShapeFactory.cpp | 32 +++++++++++++++++++ .../Public/Factory/BagShapeFactory.h | 22 +++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 ProjectFish/Source/ProjectFishEditor/Private/Factory/BagShapeFactory.cpp create mode 100644 ProjectFish/Source/ProjectFishEditor/Public/Factory/BagShapeFactory.h diff --git a/ProjectFish/Source/ProjectFishEditor/Private/Factory/BagShapeFactory.cpp b/ProjectFish/Source/ProjectFishEditor/Private/Factory/BagShapeFactory.cpp new file mode 100644 index 0000000..aab5dce --- /dev/null +++ b/ProjectFish/Source/ProjectFishEditor/Private/Factory/BagShapeFactory.cpp @@ -0,0 +1,32 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Factory/BagShapeFactory.h" + +#include "ProjectFish/DataAsset/BagShapeAsset.h" + +UBagShapeFactory::UBagShapeFactory() +{ + bCreateNew = true; + bEditAfterNew = true; + SupportedClass = UBagShapeAsset::StaticClass(); +} + +UObject* UBagShapeFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) +{ + + + UBagShapeAsset* NewBagShapeAsset = NewObject(InParent, Class, Name, Flags | RF_Transactional); + if (NewBagShapeAsset) + { + NewBagShapeAsset->BagWidth = 5; + NewBagShapeAsset->BagHeight = 5; + NewBagShapeAsset->InitializeBagShape(); + } + return NewBagShapeAsset; +} + +bool UBagShapeFactory::ShouldShowInNewMenu() const +{ + return true; +} diff --git a/ProjectFish/Source/ProjectFishEditor/Public/Factory/BagShapeFactory.h b/ProjectFish/Source/ProjectFishEditor/Public/Factory/BagShapeFactory.h new file mode 100644 index 0000000..775873f --- /dev/null +++ b/ProjectFish/Source/ProjectFishEditor/Public/Factory/BagShapeFactory.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 "BagShapeFactory.generated.h" + +/** + * + */ +UCLASS() +class PROJECTFISHEDITOR_API UBagShapeFactory : public UFactory +{ + GENERATED_BODY() +public: + UBagShapeFactory(); + + //interface + virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override; + virtual bool ShouldShowInNewMenu() const override; +};