UE4 Asset Editor Properties Detail View

UE4 Asset Editor Properties Detail View

1 Tab Factory


As mentioned in the previous article, each tab should have a tab factory class to generate tab body.


struct FTestDetailsSummoner : public FWorkflowTabFactory
{
public:
	FTestDetailsSummoner(TSharedPtr<class FTestEditor> InTestEditorPtr);
	virtual TSharedRef<SWidget> CreateTabBody(const FWorkflowTabSpawnInfo& Info) const override;
	virtual FText GetTabToolTipText(const FWorkflowTabSpawnInfo& Info) const override;

protected:
	TWeakPtr<class FTestEditor> TestEditorPtr;
};

FTestDetailsSummoner::FTestDetailsSummoner(TSharedPtr<class FTestEditor> InTestEditorPtr)
	: FWorkflowTabFactory(FTestEditorTabs::GraphDetailsID, InTestEditorPtr)
	, TestEditorPtr(InTestEditorPtr)
{
	TabLabel = LOCTEXT("TestDetailsLabel", "Details");
	TabIcon = FSlateIcon(FEditorStyle::GetStyleSetName(), "Kismet.Tabs.Components");
	bIsSingleton = true;
	ViewMenuDescription = LOCTEXT("TestDetailsView", "Details");
	ViewMenuTooltip = LOCTEXT("TestDetailsView_ToolTip", "Show the details view");
}

TSharedRef<SWidget> FTestDetailsSummoner::CreateTabBody(const FWorkflowTabSpawnInfo& Info) const
{
	check(TestEditorPtr.IsValid());
	return TestEditorPtr.Pin()->SpawnProperties();
}

FText FTestDetailsSummoner::GetTabToolTipText(const FWorkflowTabSpawnInfo& Info) const
{
	return LOCTEXT("TestDetailsTabTooltip", "The Test details tab allows editing of the properties");
}



2 Detail View


To show the properties detail, UE4 provides detail view widget (IDetailsView) to show and edit UObject properties. You can create it as follow.


void FTestEditor::CreateInternalWidgets()
{
	FPropertyEditorModule& PropertyEditorModule = FModuleManager::GetModuleChecked<FPropertyEditorModule>("PropertyEditor");
	FDetailsViewArgs DetailsViewArgs(false, false, true, FDetailsViewArgs::HideNameArea, false);
	DetailsViewArgs.NotifyHook = this;
	DetailsViewArgs.DefaultsOnlyVisibility = EEditDefaultsOnlyNodeVisibility::Hide;
	DetailsView = PropertyEditorModule.CreateDetailView(DetailsViewArgs);
	DetailsView->SetObject(NULL);
	DetailsView->SetIsPropertyEditingEnabledDelegate(FIsPropertyEditingEnabled::CreateSP(this, &FTestEditor::IsPropertyEditable));
	DetailsView->OnFinishedChangingProperties().AddSP(this, &FTestEditor::OnFinishedChangingProperties);
}

TSharedRef<SWidget> FTestEditor::SpawnProperties()
{
	return
		SNew(SVerticalBox)
		+ SVerticalBox::Slot()
		.FillHeight(1.0f)
		.HAlign(HAlign_Fill)
		[
			DetailsView.ToSharedRef()
		];
}

Call SetObject of IDetailsView to view properties of current UObject.

DetailView

  • For blueprint variable, you should set the property Instance Editable to true.

  • For C++ variable, you should add EditAnywhere tag in UPROPERTY.





Tags: UE4 Editor Vistied:
Share: Twitter Facebook LinkedIn