本文整理汇总了C++中TSharedRef::AsArray方法的典型用法代码示例。如果您正苦于以下问题:C++ TSharedRef::AsArray方法的具体用法?C++ TSharedRef::AsArray怎么用?C++ TSharedRef::AsArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TSharedRef
的用法示例。
在下文中一共展示了TSharedRef::AsArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GeneratePropertyContent
void FReplaceVectorWithLinearColorBuilder::GeneratePropertyContent(const TSharedRef<IPropertyHandle>& Handle, IDetailChildrenBuilder& ChildrenBuilder)
{
// Add to the current builder, depending on the property type.
uint32 NumChildren = 0;
ensure(Handle->GetNumChildren(NumChildren) == FPropertyAccess::Success);
bool bHasChildren = (NumChildren > 0);
bool bIsArray = Handle->AsArray().IsValid();
if (bIsArray)
{
// Arrays need special handling and will create an array builder
TSharedRef<FDetailArrayBuilder> ArrayBuilder = MakeShareable(new FDetailArrayBuilder(Handle));
ArrayBuilder->OnGenerateArrayElementWidget(FOnGenerateArrayElementWidget::CreateSP(this, &FReplaceVectorWithLinearColorBuilder::OnGenerateArrayElementWidget));
ChildrenBuilder.AddChildCustomBuilder(ArrayBuilder);
}
else if (bHasChildren)
{
// If there are children, we invoke a new instance of our custom builder for recursive handling
// Note, if this is an FVector, it will be handled specially by the implementation of the IDetailCustomNodeBuilder interface.
TSharedRef<FReplaceVectorWithLinearColorBuilder> StructBuilder = MakeShareable(new FReplaceVectorWithLinearColorBuilder(Handle));
ChildrenBuilder.AddChildCustomBuilder(StructBuilder);
}
else
{
// No children - just add the property.
ChildrenBuilder.AddChildProperty(Handle);
}
}
示例2: CustomizeDetails
void SheetEquipmentCustomization::CustomizeDetails(IDetailLayoutBuilder& DetailBuilder)
{
IDetailCategoryBuilder& Category = DetailBuilder.EditCategory("Slots", FText::GetEmpty(), ECategoryPriority::Important);
//You can get properties using the detailbuilder
TSharedRef<IPropertyHandle> BaseHandle = DetailBuilder.GetProperty("Equipment");
if (!BaseHandle->IsValidHandle())
{
Category.AddCustomRow(LOCTEXT("Fail", "Fail"))
.NameContent()
[
SNew(STextBlock)
.Text(LOCTEXT("Fail", "Fail"))
.Font(IDetailLayoutBuilder::GetDetailFont())
];
return;
}
BaseHandle->MarkHiddenByCustomization();
uint32 num;
BaseHandle->AsArray()->GetNumElements(num);
for (uint32 i = 0; i < num; i++)
{
FText text = StatEnums::EquipSlots()->GetEnumText(i);
Category.AddCustomRow(text)
.NameContent()
[
SNew(STextBlock)
.Text(text)
.Font(IDetailLayoutBuilder::GetDetailFont())
]
.ValueContent().MinDesiredWidth(500)
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
[
SNew(SProperty, BaseHandle->AsArray()->GetElement(i)->GetChildHandle("Item"))
.ShouldDisplayName(false)
]];
}
}
示例3: ConditionTranslationMetadata
void ConditionTranslationMetadata( TSharedRef<FLocMetadataValue> MetadataValue )
{
switch( MetadataValue->Type )
{
case ELocMetadataType::String:
{
TSharedPtr<FLocMetadataValue> MetadataValuePtr = MetadataValue;
TSharedPtr<FLocMetadataValueString> MetadataString = StaticCastSharedPtr<FLocMetadataValueString>( MetadataValuePtr );
MetadataString->SetString( TEXT("") );
}
break;
case ELocMetadataType::Array:
{
TArray< TSharedPtr< FLocMetadataValue > > MetadataArray = MetadataValue->AsArray();
for( auto ArrayIter = MetadataArray.CreateIterator(); ArrayIter; ++ArrayIter )
{
TSharedPtr<FLocMetadataValue>& Item = *ArrayIter;
if( Item.IsValid() )
{
ConditionTranslationMetadata( Item.ToSharedRef() );
}
}
}
break;
case ELocMetadataType::Object:
{
TSharedPtr< FLocMetadataObject > MetadataObject = MetadataValue->AsObject();
for( auto ValueIter = MetadataObject->Values.CreateConstIterator(); ValueIter; ++ValueIter )
{
const FString Name = (*ValueIter).Key;
TSharedPtr< FLocMetadataValue > Value = (*ValueIter).Value;
if( Value.IsValid() )
{
if( Value->Type == ELocMetadataType::String )
{
MetadataObject->SetStringField( Name, TEXT("") );
}
else
{
ConditionTranslationMetadata( Value.ToSharedRef() );
}
}
}
}
default:
break;
}
}
示例4: MakeShareable
TSharedPtr<FJsonValue> LocMetaDataValueToJsonValue( const TSharedRef< FLocMetadataValue > MetadataValue )
{
switch( MetadataValue->Type )
{
case ELocMetadataType::Boolean:
{
return MakeShareable( new FJsonValueBoolean( MetadataValue->AsBool() ) );
}
break;
case ELocMetadataType::String:
{
return MakeShareable( new FJsonValueString( MetadataValue->AsString() ) );
}
break;
case ELocMetadataType::Array:
{
TArray< TSharedPtr<FJsonValue> > JsonArrayVals;
TArray< TSharedPtr< FLocMetadataValue > > MetaDataArray = MetadataValue->AsArray();
MetaDataArray.Sort( FCompareLocMetadataValue() );
for( auto ArrayIter = MetaDataArray.CreateConstIterator(); ArrayIter; ++ArrayIter )
{
const TSharedPtr<FLocMetadataValue>& Item = *ArrayIter;
if( Item.IsValid() )
{
TSharedPtr<FJsonValue> Entry = LocMetaDataValueToJsonValue( Item.ToSharedRef() );
if( Entry.IsValid() )
{
JsonArrayVals.Add( Entry );
}
}
}
if( JsonArrayVals.Num() > 0 )
{
return MakeShareable( new FJsonValueArray( JsonArrayVals ) );
}
}
break;
case ELocMetadataType::Object:
{
TSharedPtr< FJsonObject > JsonSubObject = MakeShareable( new FJsonObject );
TSharedPtr< FLocMetadataObject > MetaDataObject = MetadataValue->AsObject();
for( auto ValueIter = MetaDataObject->Values.CreateConstIterator(); ValueIter; ++ValueIter )
{
const FString Name = (*ValueIter).Key;
TSharedPtr< FLocMetadataValue > Value = (*ValueIter).Value;
if( Value.IsValid() )
{
TSharedPtr< FJsonValue > JsonValue = LocMetaDataValueToJsonValue( Value.ToSharedRef() );
if( JsonValue.IsValid() )
{
JsonSubObject->SetField( Name, JsonValue );
}
}
}
// Sorting by key is probably sufficient for now but ideally we would sort the resulting json object using
// the same logic that is in the FLocMetadata < operator
JsonSubObject->Values.KeySort( TLess<FString>() );
return MakeShareable( new FJsonValueObject(JsonSubObject) );
}
default:
break;
}
return NULL;
}