UE4 extension adds the resource filtering menu, and ue4 extension resource Filtering

Source: Internet
Author: User

UE4 extension adds the resource filtering menu, and ue4 extension resource Filtering

Now we have C ++ class C_A, blueprint class B _A, B _ B, and B _C (all inherit from C_A). Now we want to make a resource selection interface in the editor, do all the selected objects inherit all the blueprint classes of C_A?

The CreateAssetPicker function of the "ContentBrowser" module is used. The "ContentBrowser" module is part of the content browser in the editor. Before calling the CreateAssetPicker function, you must first construct the FAssetPickerConfig parameter. this parameter is mainly used to select resource filtering conditions. The call is as follows:

static const FName PosParentClassTagName(TEXT("ParentClass"));static const FString PosClassPath(TEXT("Class'/Script/AAA.C_A'"));TSharedRef<SWidget> FPaladinSequenceTemplete::CreateAssetPicker(FName AssertName, FOnAssetSelected OnAssetSelected,bool Actor){FAssetPickerConfig AssetPickerConfig;{AssetPickerConfig.OnAssetSelected = OnAssetSelected;AssetPickerConfig.bAllowNullSelection = false;AssetPickerConfig.InitialAssetViewType = EAssetViewType::List;AssetPickerConfig.Filter.bRecursiveClasses = true;AssetPickerConfig.Filter.ClassNames.Add(AssertName);AssetPickerConfig.Filter.TagsAndValues.Add(PosParentClassTagName, PosClassPath);}FContentBrowserModule& ContentBrowserModule = FModuleManager::Get().LoadModuleChecked<FContentBrowserModule>(TEXT("ContentBrowser"));return SNew(SBox).WidthOverride(300.0f).HeightOverride(300.f)[ContentBrowserModule.Get().CreateAssetPicker(AssetPickerConfig)];}

Note the following points:

1. assetPickerConfig. filter. classNames: The ClassName of UBlueprint is required instead of the ClassName of your c ++ class. You can search for your resources in the content browser and you will find that the filtering condition is a blueprint class, this is a truth.

2. It is not enough to filter only UBlueprint. In this way, all the blueprint classes will be found and further restrictions must be added. The constraint is that the blueprint class and the parent class is AAA. C_A. In this case, another parameter Filter. TagsAndValues is used. View the UBlueprint class declaration and you will find some attributes marked as AssetRegistrySearchable. This attribute is provided for query here. Our filtering condition is that the ParentClass in UBlueprint is all the blueprint classes of C_A, so we can insert this key-value pair into TagsAndValues.

You can create a filter window through the above steps. After you select a resource, the callback function (AssetPickerConfig. OnAssetSelected) selected by the resource will be called. The parameter is const FAssetData & type. Note the following points for the selected B _A:

1. FAssetData. AssetClass is still of the UBlueprint type. It cannot be C_A or the C ++ type generated in the middle.

2. FAssetData. GetAsset () returns the pointer type of the UBlueprint object.

3. we declare a function in C_A. The UFUNCTION is specified as BlueprintImplementableEvent, which requires the implementation of the blueprint class. The function name is int GetDebugInfo (); B _A, B _ B, B _C inherits C_A, overrides the GetDebugInfo function, and returns 1, 2, and 3 in sequence. If we have a blueprint class object, we can directly call GetDebugInfo to obtain data. If we have data of the blueprint class TSubClassOf <C_A>, you can call CDO to convert to C_A and call GetDebugInfo to obtain data. If we only have FAssetData, we can use FAssetData. getAsset obtains the object data of UBlueprint, and then obtains the type data of the C ++ class generated by the blueprint class UBlueprint. generatedClass, and obtain UBlueprint. generatedClass CDO, and then call GetDebugInfo.

Each blueprint class B _A, B _ B, and B _C has a corresponding C ++ class (which should be generated by the blueprint system). The type data is stored in UBlueprint. GeneratedClass.


Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger. Http://blog.csdn.net/hui211314ddhui/article/details/79443846

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.