.h:
class UMySettingsObject : public UObject
{
// GENERATED_BODY()
public:
// 构造函数
UMySettingsObject();
///**设置Actor对象 */
UPROPERTY(EditAnywhere, Category = Settings, meta = (DisplayName = "Actor对象"))
AActor* TestActor;
};
class FHumanSettingDetails : public IDetailCustomization
{
public:
FHumanSettingDetails(TSharedPtr<STextBlock> InConfigCardTextBlock)
: ConfigCardTextBlock(InConfigCardTextBlock) {}
virtual void CustomizeDetails(IDetailLayoutBuilder& DetailBuilder) override;
static TSharedRef<IDetailCustomization> MakeInstance(TSharedPtr<STextBlock> InConfigCardTextBlock)
{
return MakeShareable(new FHumanSettingDetails(InConfigCardTextBlock));
}
private:
void OnCharacterNameChanged(const FText& NewText);
TWeakPtr<STextBlock> ConfigCardTextBlock;
TSharedPtr<SEditableTextBox> CharacterNameTextBox;
TSharedPtr<SComboBox<TSharedPtr<FString>>> VoiceModelTypeComboBox;
TSharedPtr<SComboBox<TSharedPtr<FString>>> SoVITSWeightsComboBox;
TSharedPtr<SComboBox<TSharedPtr<FString>>> GPTWeightsComboBox;
TSharedPtr<SEditableTextBox> IPAddressTextBox;
TSharedPtr<SEditableTextBox> PortTextBox;
TSharedPtr<SCheckBox> NativeIPAddressCheckBox;
TSharedPtr<SCheckBox> AutoConfigureIPCheckBox;
TSharedPtr<SComboBox<TSharedPtr<AActor>>> ActorComboBox;
};
.cpp:
void FHumanSettingDetails::CustomizeDetails(IDetailLayoutBuilder& DetailBuilder)
{
IDetailCategoryBuilder& Category = DetailBuilder.EditCategory("Settings", LOCTEXT("SettingsCategory", "设置"), ECategoryPriority::Default);
I have tried:
IDetailCategoryBuilder& Category = DetailBuilder.EditCategory("Settings", LOCTEXT("SettingsCategory", "Settings"), ECategoryPriority::Default);
// Get the Property Handle of GangBangActor properties
TSharedRef<IPropertyHandle> TestActorHandle = DetailBuilder.GetProperty(GET_MEMBER_NAME_CHECKED(UMySettingsObject, TestActor));
// Check if the Property Handle is valid
if (TestActorHandle->IsValidHandle())
{
// Add the Property Handle to the Category
Category.AddProperty(TestActorHandle);
}
else
{
// Output debug information
UE_LOG(LogTemp, Warning, TEXT("Invalid Property Handle for TestActor"));
}
}
2. Category.AddProperty(GET_MEMBER_NAME_CHECKED(UMySettingsObject, TestActor));
In the above two attempts, the code does not report an error, but the attribute is not added. What should I do?