当前位置: 首页>>代码示例>>C++>>正文


C++ TSharedRef::AsArray方法代码示例

本文整理汇总了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);
	}
}
开发者ID:Codermay,项目名称:Unreal4,代码行数:28,代码来源:RawDistributionVectorStructCustomization.cpp

示例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)
            ]];
    }
}
开发者ID:sblack,项目名称:DehrgadaTWU,代码行数:43,代码来源:SheetEquipmentCustomization.cpp

示例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;
    }
}
开发者ID:kidaa,项目名称:UnrealEngineVR,代码行数:51,代码来源:GenerateGatherArchiveCommandlet.cpp

示例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;
}
开发者ID:Art1stical,项目名称:AHRUnrealEngine,代码行数:72,代码来源:JsonInternationalizationMetadataSerializer.cpp


注:本文中的TSharedRef::AsArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。