UCLASS() class UICUSTOM_API UMyObject : public UObject { GENERATED_BODY() public: UPROPERTY(EditAnywhere, Category = "My Object Properties") FString Name; };
UCLASS() class UICUSTOM_API UMyObjectFactory : public UFactory { GENERATED_UCLASS_BODY() // UFactory interface virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override; // End of UFactory interface virtual bool CanCreateNew() const override; };
UObject* UMyObjectFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) { UMyObject* NewObjectAsset = NewObject<UMyObject>(InParent,Class, Name, Flags | RF_Transactional); return NewObjectAsset; }
class UICUSTOM_API FMyObjectAssetAction : public FAssetTypeActions_Base { public: virtual FText GetName() const override; virtual FColor GetTypeColor() const override; virtual UClass* GetSupportedClass() const override; virtual bool HasActions(const TArray<UObject*>& InObjects) const override { return false; } virtual uint32 GetCategories() override; static void RegistrateCustomPartAssetType(); };
AUICustomGameMode::AUICustomGameMode() { #if WITH_EDITORONLY_DATA FMyClassDetails::RegestrateCostumization(); FMyObjectAssetAction::RegistrateCustomPartAssetType(); #endif //WITH_EDITORONLY_DATA }
UCLASS() class UICUSTOM_API ATestAct : public AActor { GENERATED_BODY() public: // Sets default values for this actor's properties ATestAct(); // Called when the game starts or when spawned virtual void BeginPlay() override; // Called every frame virtual void Tick( float DeltaSeconds ) override; UPROPERTY(EditAnywhere, BlueprintReadWrite) UMyObject* MyObject; };
class FMyClassDetails : public IDetailCustomization { public: static FReply MClick(IDetailLayoutBuilder* DetailBuilder); /** Makes a new instance of this detail layout class for a specific detail view requesting it */ static TSharedRef<IDetailCustomization> MakeInstance(); static void RegestrateCostumization(); /** IDetailCustomization interface */ virtual void CustomizeDetails(IDetailLayoutBuilder& DetailBuilder) override; static void ShowNotification(FText Text, SNotificationItem::ECompletionState State = SNotificationItem::CS_None); static ATestAct* GetObject(IDetailLayoutBuilder* DetailBuilder); };
void FMyClassDetails::CustomizeDetails(IDetailLayoutBuilder& DetailBuilder) { // Create a category so this is displayed early in the properties ATestAct* TestAct = GetObject(&DetailBuilder); IDetailCategoryBuilder& MyCategory = DetailBuilder.EditCategory("Button", FText::GetEmpty(), ECategoryPriority::Important); //You can get properties using the detailbuilder //MyProperty= DetailBuilder.GetProperty(GET_MEMBER_NAME_CHECKED(MyClass, MyClassPropertyName)); FText TestHUDText = FText::FromString("Your Text"); MyCategory.AddCustomRow(TestHUDText) .ValueContent() //NameContent() [ SNew(SButton) .Text(FText::FromString("ShowMessage")) .OnClicked(FOnClicked::CreateStatic(&FMyClassDetails::MClick, &DetailBuilder)) ]; }
void FMyClassDetails::RegestrateCostumization() { FPropertyEditorModule& PropertyModule = FModuleManager::LoadModuleChecked<FPropertyEditorModule>("PropertyEditor"); //Custom detail views PropertyModule.RegisterCustomClassLayout("TestAct", FOnGetDetailCustomizationInstance::CreateStatic(&FMyClassDetails::MakeInstance)); }
SNew(SHorizontalBox) + SHorizontalBox::Slot() [ SNew(SButton) .Text(FText::FromString("OK")) ] + SHorizontalBox::Slot() [ SNew(SButton) .Text(FText::FromString("OK")) ]
TSharedPtr<SHorizontalBox> Container = SNew(SHorizontalBox); for (int32 idx = 0; idx < 2; idx++) { Container->AddSlot() [ SNew(SButton) .Text(FText::FromString("OK")) ]; } MyCategory.AddCustomRow(TestHUDText) .ValueContent() [ Container.ToSharedRef() ];
Source: https://habr.com/ru/post/274159/
All Articles