Added the ability to have "DisallowedClasses" metadata to prevent certain assets from being assigned to references.

SlateBrush no longer allowes UMediaTextures.

#jira UE-63861
#rb Matt.Kuhlenschmidt
#codereview Matt.Kuhlenschmidt, Michael.Noland, Ben.Ziegler, Chris.Babcock, Rex.Hill

[CL 4356067 by Chris Gagnon in Dev-Editor branch]
This commit is contained in:
Chris Gagnon
2018-09-10 17:16:07 -04:00
parent 9bbea69438
commit e4ade19fcc
10 changed files with 209 additions and 44 deletions

View File

@@ -263,12 +263,24 @@ namespace PropertyCustomizationHelpers
.OnAssetSelected( OnAssetSelectedFromPicker );
}
TArray<const UClass*> EmptyClassArray;
TSharedRef<SWidget> MakeAssetPickerWithMenu(const FAssetData& InitialObject, const bool AllowClear, const TArray<const UClass*>& AllowedClasses, const TArray<UFactory*>& NewAssetFactories, FOnShouldFilterAsset OnShouldFilterAsset, FOnAssetSelected OnSet, FSimpleDelegate OnClose)
{
return MakeAssetPickerWithMenu(InitialObject, AllowClear, false, AllowedClasses, NewAssetFactories, OnShouldFilterAsset, OnSet, OnClose);
return MakeAssetPickerWithMenu(InitialObject, AllowClear, false, AllowedClasses, EmptyClassArray, NewAssetFactories, OnShouldFilterAsset, OnSet, OnClose);
}
TSharedRef<SWidget> MakeAssetPickerWithMenu( const FAssetData& InitialObject, const bool AllowClear, const bool AllowCopyPaste, const TArray<const UClass*>& AllowedClasses, const TArray<UFactory*>& NewAssetFactories, FOnShouldFilterAsset OnShouldFilterAsset, FOnAssetSelected OnSet, FSimpleDelegate OnClose)
TSharedRef<SWidget> MakeAssetPickerWithMenu(const FAssetData& InitialObject, const bool AllowClear, const TArray<const UClass*>& AllowedClasses, const TArray<const UClass*>& DisallowedClasses, const TArray<UFactory*>& NewAssetFactories, FOnShouldFilterAsset OnShouldFilterAsset, FOnAssetSelected OnSet, FSimpleDelegate OnClose)
{
return MakeAssetPickerWithMenu(InitialObject, AllowClear, false, AllowedClasses, DisallowedClasses, NewAssetFactories, OnShouldFilterAsset, OnSet, OnClose);
}
TSharedRef<SWidget> MakeAssetPickerWithMenu(const FAssetData& InitialObject, const bool AllowClear, const bool AllowCopyPaste, const TArray<const UClass*>& AllowedClasses, const TArray<UFactory*>& NewAssetFactories, FOnShouldFilterAsset OnShouldFilterAsset, FOnAssetSelected OnSet, FSimpleDelegate OnClose)
{
return MakeAssetPickerWithMenu(InitialObject, AllowClear, AllowCopyPaste, AllowedClasses, EmptyClassArray, NewAssetFactories, OnShouldFilterAsset, OnSet, OnClose);
}
TSharedRef<SWidget> MakeAssetPickerWithMenu( const FAssetData& InitialObject, const bool AllowClear, const bool AllowCopyPaste, const TArray<const UClass*>& AllowedClasses, const TArray<const UClass*>& DisallowedClasses, const TArray<UFactory*>& NewAssetFactories, FOnShouldFilterAsset OnShouldFilterAsset, FOnAssetSelected OnSet, FSimpleDelegate OnClose)
{
return
SNew(SPropertyMenuAssetPicker)
@@ -276,6 +288,7 @@ namespace PropertyCustomizationHelpers
.AllowClear(AllowClear)
.AllowCopyPaste(AllowCopyPaste)
.AllowedClasses(AllowedClasses)
.DisallowedClasses(DisallowedClasses)
.NewAssetFactories(NewAssetFactories)
.OnShouldFilterAsset(OnShouldFilterAsset)
.OnSet(OnSet)
@@ -383,6 +396,11 @@ namespace PropertyCustomizationHelpers
}
TArray<UFactory*> GetNewAssetFactoriesForClasses(const TArray<const UClass*>& Classes)
{
return GetNewAssetFactoriesForClasses(Classes, EmptyClassArray);
}
TArray<UFactory*> GetNewAssetFactoriesForClasses(const TArray<const UClass*>& Classes, const TArray<const UClass*>& DisallowedClasses)
{
TArray<UFactory*> Factories;
for (TObjectIterator<UClass> It; It; ++It)
@@ -394,7 +412,9 @@ namespace PropertyCustomizationHelpers
if (Factory->ShouldShowInNewMenu() && ensure(!Factory->GetDisplayName().IsEmpty()))
{
UClass* SupportedClass = Factory->GetSupportedClass();
if (SupportedClass != nullptr && Classes.ContainsByPredicate([=](const UClass* InClass) { return SupportedClass->IsChildOf(InClass); }))
if (SupportedClass != nullptr
&& Classes.ContainsByPredicate([=](const UClass* InClass) { return SupportedClass->IsChildOf(InClass); })
&& !DisallowedClasses.ContainsByPredicate([=](const UClass* InClass) { return SupportedClass->IsChildOf(InClass); }))
{
Factories.Add(Factory);
}