本文整理汇总了C++中UProperty::GetMetaData方法的典型用法代码示例。如果您正苦于以下问题:C++ UProperty::GetMetaData方法的具体用法?C++ UProperty::GetMetaData怎么用?C++ UProperty::GetMetaData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UProperty
的用法示例。
在下文中一共展示了UProperty::GetMetaData方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ImportConsoleVariableValues
void UDeveloperSettings::ImportConsoleVariableValues()
{
for (UProperty* Property = GetClass()->PropertyLink; Property; Property = Property->PropertyLinkNext)
{
if (!Property->HasAnyPropertyFlags(CPF_Config))
{
continue;
}
FString CVarName = Property->GetMetaData(DeveloperSettingsConsoleVariableMetaFName);
if (!CVarName.IsEmpty())
{
IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(*CVarName);
if (CVar)
{
if (Property->ImportText(*CVar->GetString(), Property->ContainerPtrToValuePtr<uint8>(this, 0), PPF_ConsoleVariable, this) == NULL)
{
UE_LOG(LogTemp, Error, TEXT("%s import failed for %s on console variable %s (=%s)"), *GetClass()->GetName(), *Property->GetName(), *CVarName, *CVar->GetString());
}
}
else
{
UE_LOG(LogTemp, Fatal, TEXT("%s failed to find console variable %s for %s"), *GetClass()->GetName(), *CVarName, *Property->GetName());
}
}
}
}
示例2: DisplayNameKey
static UProperty *get_field_from_name(UScriptStruct *u_struct, char *name)
{
FString attr = UTF8_TO_TCHAR(name);
UProperty *u_property = u_struct->FindPropertyByName(FName(*attr));
if (u_property)
return u_property;
#if WITH_EDITOR
static const FName DisplayNameKey(TEXT("DisplayName"));
// if the property is not found, attempt to search for DisplayName
for (TFieldIterator<UProperty> prop(u_struct); prop; ++prop)
{
UProperty *property = *prop;
if (property->HasMetaData(DisplayNameKey))
{
FString display_name = property->GetMetaData(DisplayNameKey);
if (display_name.Len() > 0 && attr.Equals(display_name))
{
return property;
}
}
}
#endif
return nullptr;
}
示例3: Construct
void SPropertyEditorAsset::Construct( const FArguments& InArgs, const TSharedPtr<FPropertyEditor>& InPropertyEditor )
{
PropertyEditor = InPropertyEditor;
PropertyHandle = InArgs._PropertyHandle;
OnSetObject = InArgs._OnSetObject;
OnShouldFilterAsset = InArgs._OnShouldFilterAsset;
UProperty* Property = nullptr;
if(PropertyEditor.IsValid())
{
Property = PropertyEditor->GetPropertyNode()->GetProperty();
UObjectPropertyBase* ObjectProperty = Cast<UObjectPropertyBase>(Property);
check(ObjectProperty);
bAllowClear = !(Property->PropertyFlags & CPF_NoClear);
ObjectClass = ObjectProperty->PropertyClass;
bIsActor = ObjectProperty->PropertyClass->IsChildOf( AActor::StaticClass() );
}
else
{
bAllowClear = InArgs._AllowClear;
ObjectPath = InArgs._ObjectPath;
ObjectClass = InArgs._Class;
bIsActor = ObjectClass->IsChildOf( AActor::StaticClass() );
if (PropertyHandle.IsValid() && PropertyHandle->IsValidHandle())
{
Property = PropertyHandle->GetProperty();
}
else
{
CustomClassFilters.Add(ObjectClass);
}
}
// Account for the allowed classes specified in the property metadata
if (Property)
{
FString ClassFilterString;
if (UArrayProperty* ArrayParent = Cast<UArrayProperty>(Property->GetOuter()))
{
ClassFilterString = ArrayParent->GetMetaData("AllowedClasses");
}
else
{
ClassFilterString = Property->GetMetaData("AllowedClasses");
}
if (ClassFilterString.IsEmpty())
{
CustomClassFilters.Add(ObjectClass);
}
else
{
TArray<FString> CustomClassFilterNames;
ClassFilterString.ParseIntoArray(CustomClassFilterNames, TEXT(","), true);
for (auto It = CustomClassFilterNames.CreateConstIterator(); It; ++It)
{
const FString& ClassName = *It;
UClass* Class = FindObject<UClass>(ANY_PACKAGE, *ClassName);
if (!Class)
{
Class = LoadObject<UClass>(nullptr, *ClassName);
}
if (Class)
{
// If the class is an interface, expand it to be all classes in memory that implement the class.
if (Class->HasAnyClassFlags(CLASS_Interface))
{
for (TObjectIterator<UClass> ClassIt; ClassIt; ++ClassIt)
{
UClass* const ClassWithInterface = (*ClassIt);
if (ClassWithInterface->ImplementsInterface(Class))
{
CustomClassFilters.Add(ClassWithInterface);
}
}
}
else
{
CustomClassFilters.Add(Class);
}
}
}
}
}
if (InArgs._NewAssetFactories.IsSet())
{
NewAssetFactories = InArgs._NewAssetFactories.GetValue();
}
else if (CustomClassFilters.Num() > 1 || !CustomClassFilters.Contains(UObject::StaticClass()))
{
NewAssetFactories = PropertyCustomizationHelpers::GetNewAssetFactoriesForClasses(CustomClassFilters);
}
//.........这里部分代码省略.........
示例4: MakeNewBlueprint
void FPropertyEditor::MakeNewBlueprint()
{
UProperty* NodeProperty = PropertyNode->GetProperty();
UClassProperty* ClassProp = Cast<UClassProperty>(NodeProperty);
UClass* Class = (ClassProp ? ClassProp->MetaClass : FEditorClassUtils::GetClassFromString(NodeProperty->GetMetaData("MetaClass")));
if (Class)
{
UBlueprint* Blueprint = FKismetEditorUtilities::CreateBlueprintFromClass(LOCTEXT("CreateNewBlueprint", "Create New Blueprint"), Class, FString::Printf(TEXT("New%s"),*Class->GetName()));
if(Blueprint != NULL && Blueprint->GeneratedClass)
{
PropertyHandle->SetValueFromFormattedString(Blueprint->GeneratedClass->GetPathName());
FAssetEditorManager::Get().OpenEditorForAsset(Blueprint);
}
}
}
示例5: CustomizeDetails
//.........这里部分代码省略.........
.HAlign(HAlign_Left)
[
SNew(SButton)
.VAlign(VAlign_Center)
.OnClicked(this, &FPaperTileMapDetailsCustomization::EnterTileMapEditingMode)
.Visibility(this, &FPaperTileMapDetailsCustomization::GetNonEditModeVisibility)
.Text( LOCTEXT("EditAsset", "Edit") )
.ToolTipText( LOCTEXT("EditAssetToolTip", "Edit this tile map") )
]
// Create new tile map button
+SHorizontalBox::Slot()
.AutoWidth()
.Padding( 2.0f, 0.0f )
.VAlign(VAlign_Center)
.HAlign(HAlign_Left)
[
SNew(SButton)
.VAlign(VAlign_Center)
.OnClicked(this, &FPaperTileMapDetailsCustomization::OnNewButtonClicked)
.Visibility(this, &FPaperTileMapDetailsCustomization::GetNewButtonVisiblity)
.Text(LOCTEXT("CreateNewInstancedMap", "New"))
.ToolTipText( LOCTEXT("CreateNewInstancedMapToolTip", "Create a new tile map") )
]
// Promote to asset button
+SHorizontalBox::Slot()
.AutoWidth()
.Padding( 2.0f, 0.0f )
.VAlign(VAlign_Center)
.HAlign(HAlign_Left)
[
SNew(SButton)
.VAlign(VAlign_Center)
.OnClicked(this, &FPaperTileMapDetailsCustomization::OnPromoteButtonClicked)
.Visibility(this, &FPaperTileMapDetailsCustomization::GetVisibilityForInstancedOnlyProperties)
.Text(LOCTEXT("PromoteToAsset", "Promote to asset"))
.ToolTipText(LOCTEXT("PromoteToAssetToolTip", "Save this tile map as a reusable asset"))
]
]
];
TileMapCategory.AddProperty(GET_MEMBER_NAME_CHECKED(UPaperTileMapComponent, TileMap));
}
// Add the layer browser
if (TileMap != nullptr)
{
TAttribute<EVisibility> LayerBrowserVis;
LayerBrowserVis.Set(EVisibility::Visible);
if (TileComponent != nullptr)
{
LayerBrowserVis = InternalInstanceVis;
}
FText TileLayerListText = LOCTEXT("TileLayerList", "Tile layer list");
TileMapCategory.AddCustomRow(TileLayerListText)
.Visibility(LayerBrowserVis)
[
SNew(SVerticalBox)
+SVerticalBox::Slot()
.AutoHeight()
[
SNew(STextBlock)
.Font(DetailLayout.GetDetailFont())
.Text(TileLayerListText)
]
+SVerticalBox::Slot()
[
SNew(STileLayerList, TileMap, NotifyHook)
]
];
}
// Add all of the properties from the inline tilemap
if ((TileComponent != nullptr) && (TileComponent->OwnsTileMap()))
{
TArray<UObject*> ListOfTileMaps;
ListOfTileMaps.Add(TileMap);
for (TFieldIterator<UProperty> PropIt(UPaperTileMap::StaticClass()); PropIt; ++PropIt)
{
UProperty* TestProperty = *PropIt;
if (TestProperty->HasAnyPropertyFlags(CPF_Edit))
{
FName CategoryName(*TestProperty->GetMetaData(TEXT("Category")));
IDetailCategoryBuilder& Category = DetailLayout.EditCategory(CategoryName);
if (IDetailPropertyRow* ExternalRow = Category.AddExternalProperty(ListOfTileMaps, TestProperty->GetFName()))
{
ExternalRow->Visibility(InternalInstanceVis);
}
}
}
}
// Make sure the setup category is near the top
DetailLayout.EditCategory("Setup");
}
示例6: Construct
void SGAAttributeWidget::Construct(const FArguments& InArgs)
{
AttributesList.Empty();
AttributesNodes.Empty();
OnAttributeSelected = InArgs._OnAttributeSelectedIn;
/*
Intended look:
ClassName
--CategoryName
----AttributeName
Or:
ClassName
--CategoryName
----AttributeType
------AttributeName
+ search. We really need search!
*/
for (TObjectIterator<UClass> ClassIt; ClassIt; ++ClassIt)
{
UClass* Class = *ClassIt;
if (Class->IsChildOf(UGAAttributesBase::StaticClass())
&& !FKismetEditorUtilities::IsClassABlueprintSkeleton(Class))
{
FString className = Class->GetName();
if (!className.Contains(TEXT("REINST_")))
{
TSharedPtr<FGAAttributeNode> classRootNode = MakeShareable(new FGAAttributeNode());
classRootNode->Attribute = className;
//first let's find root of tree, which is class name
classRootNode->NodeName = className;
FString Category;
//now let's categories as childs
for (TFieldIterator<UProperty> PropertyIt(Class, EFieldIteratorFlags::ExcludeSuper); PropertyIt; ++PropertyIt)
{
UProperty* Prop = *PropertyIt;
Category = Prop->GetMetaData("Category");
//check if we already have this category added..
bool bFoundExistingCategory = false;
if (!Category.IsEmpty())
{
for (TSharedPtr<FGAAttributeNode> childNode : classRootNode->ChildNodes)
{
if (childNode->NodeName == Category)
{
bFoundExistingCategory = true;
TSharedPtr<FGAAttributeNode> attrNode = MakeShareable(new FGAAttributeNode());
attrNode->NodeName = Prop->GetName();
attrNode->ParentNode = childNode;
childNode->ChildNodes.Add(attrNode);
}
}
if (!bFoundExistingCategory)
{
TSharedPtr<FGAAttributeNode> categoryNode = MakeShareable(new FGAAttributeNode());
categoryNode->NodeName = Category;
categoryNode->ParentNode = classRootNode;
classRootNode->ChildNodes.Add(categoryNode);
TSharedPtr<FGAAttributeNode> attrNode = MakeShareable(new FGAAttributeNode());
attrNode->NodeName = Prop->GetName();
attrNode->ParentNode = categoryNode;
categoryNode->ChildNodes.Add(attrNode);
}
}
}
AttributesNodes.Add(classRootNode);
}
}
}
ChildSlot
[
SAssignNew(AttributeTreeWidget, STreeView<TSharedPtr<FGAAttributeNode>>)
.OnSelectionChanged(this, &SGAAttributeWidget::OnItemSelected)
.TreeItemsSource(&AttributesNodes)
.OnGenerateRow(this, &SGAAttributeWidget::OnGenerateRow)
.OnGetChildren(this, &SGAAttributeWidget::OnGetChildren)
.OnExpansionChanged(this, &SGAAttributeWidget::OnExpansionChanged)
.SelectionMode(ESelectionMode::Single)
];
}