Details视图定制

一个Actor或Property的Details信息的展示界面,可以定制。这项工作涉及几个基本的接口:
以上需要引用【PropertyEditor】模块。
代码示例:
针对特定Class类型的所有实例定制其Details面板的情形:
 StarupModule() {
	 FPropertyEditorModule& PropertyModule = FModuleManager::LoadModuleChecked<FPropertyEditorModule>(TEXT("PropertyEditor"));
	 // Custom Class Layouts
	 auto AddCustomClass = [this, InPropertyModule = &PropertyModule](FName Name, FOnGetDetailCustomizationInstance InstanceGetter)
	 {
		InPropertyModule->RegisterCustomClassLayout(Name, InstanceGetter);
		CustomClassLayoutNames.Add(Name);
	 };
	 AddCustomClass(ASURACameraDriver::StaticClass()->GetFName(), FOnGetDetailCustomizationInstance::CreateStatic(&FSURACameraDriverDetailsCustomization::MakeInstance));
 }
 ShutdownModule() {
	 if (FModuleManager::Get().IsModuleLoaded("PropertyEditor"))
	 {
		FPropertyEditorModule& PropertyModule = FModuleManager::GetModuleChecked<FPropertyEditorModule>("PropertyEditor");
		for (FName ClassName : CustomClassLayoutNames)
		{
			PropertyModule.UnregisterCustomClassLayout(ClassName);
		}
		CustomClassLayoutNames.Reset();
	 }
 }
 // .h
 TArray<FName> CustomClassLayoutNames;
针对特定Class类型的某个实例定制Details面板。需要在该实例对应的IDetailsView中设置,详见代码 Customizations/SURACameraDriverDetailsCustomization代码
IDetailsView面板与UObject建立关联:
 TSharedRef<SWidget> SSURAAR_MainWnd::MakeSURACameraDriverDetails( )
 {
	FPropertyEditorModule& PropertyModule = FModuleManager::LoadModuleChecked<FPropertyEditorModule>(TEXT("PropertyEditor"));
	FDetailsViewArgs Args;
        Args.bAllowSearch = false; // 隐藏Details面板的搜索框
	Args.NameAreaSettings = FDetailsViewArgs::HideNameArea; // 隐藏Details面板的角色名框
	TSharedRef<IDetailsView> View = PropertyModule.CreateDetailView(Args);
	View->RegisterInstancedCustomPropertyLayout(ASURACameraDriver::StaticClass(), FOnGetDetailCustomizationInstance::CreateStatic(&FSURACameraDriverDetailsCustomization::MakeInstance));
	TArray<AActor*> OutActors;
	if (GWorld)
	{
		UGameplayStatics::GetAllActorsOfClass(GWorld, ASURACameraDriver::StaticClass(), OutActors);
	}
	if (OutActors.Num() > 0)
	{
		View->SetObject(OutActors[0], true);
	}
	return View;
 }