Add a new custom detail panel, write the default value of UPROPERTY with EditIilineNew

007havegone
Tue, 12 Mar 2024 07:29:54 +0000
Programming & Scripting

I use the plugin UE4-EditorScriptingToolsPlugin(GitHub - HoussineMehnik/UE4-EditorScriptingToolsPlugin: Extend and customize some part the Unreal Editor using Blueprints. The plugin comes with some basic tools samples.) to extend my detail panel of a UCustomComponent .
In this class, it has the array of struct object.

UCLASS(BlueprintType)
class DEMO_API UCustomComponent : public UActorComponent
{
 ....
protected:
    UPROPERTY(BlueprintReadWrite, EditAnywhere,)
    TArray<FAttributesKeyValuePair> AttributePairs;
};
UCLASS(BlueprintType)

USTRUCT(BlueprintType)
struct FAttributesKeyValuePair
{
	GENERATED_BODY()
	UPROPERTY(BlueprintReadWrite, EditAnywhere)
	TObjectPtr<UAttributeSet> AttrSet;
};
UCLASS(DefaultToInstanced, Blueprintable, EditInlineNew)
class DEMO_API UAttributeSet : public UObject
{
UPROPERTY(EditAnyWhere, BlueprintReadWrite)
    int num;
};

When I add this componennt in a actor blueprint.
Click the component can see the default uproperty info in the panel.

I add the new category and widget using the UE4-EditorScriptingToolsPlugin(Create a new DetailCustomizationInstance, it can get the Customized Objects in OnCustomizeDetailsEvent),
In my cutsom widget, It contains new button, click it, I’d like to add the new instace of AttributePairs.

In DetailCustomizationInstance BP, I can read the property data about the selection compoent from the Customized Objects, I try to write the Customized Objects to do it.

It easy to create the struct object, which is copy type.
However, I use ConstructObjectFromClass to create a UAttributeSet(outer set to the customize object), when I click the custom button, It’s normal to add the default value in detail panel.
However, when I drop a instance of blueprint into level, the map can not save .
I don’t known how to create the right object for ObjectPtr. Help Please.

1 post - 1 participant