void SAssetDialog::CommitObjectPathForSave() { if ( ensure(DialogType == EAssetDialogType::Save) ) { if ( bLastInputValidityCheckSuccessful ) { const FString ObjectPath = GetObjectPathForSave(); bool bProceedWithSave = true; // If we were asked to warn on existing assets, do it now if ( ExistingAssetPolicy == ESaveAssetDialogExistingAssetPolicy::AllowButWarn ) { FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry"); FAssetData ExistingAsset = AssetRegistryModule.Get().GetAssetByObjectPath(FName(*ObjectPath)); if ( ExistingAsset.IsValid() && AssetClassNames.Contains(ExistingAsset.AssetClass) ) { EAppReturnType::Type ShouldReplace = FMessageDialog::Open( EAppMsgType::YesNo, FText::Format(LOCTEXT("ReplaceAssetMessage", "{ExistingAsset} already exists. Do you want to replace it?"), FText::FromString(CurrentlyEnteredAssetName)) ); bProceedWithSave = (ShouldReplace == EAppReturnType::Yes); } } if ( bProceedWithSave ) { OnObjectPathChosenForSave.ExecuteIfBound(ObjectPath); CloseDialog(); } } } }
//------------------------------------------------------------------------------ bool FBlueprintActionDatabaseRegistrar::IsOpenForRegistration(FAssetData const& AssetKey) { UObject const* OwnerKey = GeneratingClass; if (AssetKey.IsAssetLoaded()) { OwnerKey = AssetKey.GetAsset(); } return IsOpenForRegistration(OwnerKey); }
bool UPaperFlipbookActorFactory::CanCreateActorFrom(const FAssetData& AssetData, FText& OutErrorMsg) { if (AssetData.IsValid() && AssetData.GetClass()->IsChildOf(UPaperFlipbook::StaticClass())) { return true; } else { OutErrorMsg = NSLOCTEXT("Paper2D", "CanCreateActorFrom_NoFlipbook", "No flipbook was specified."); return false; } }
bool UVoreealBasicVolumeActorFactory::CanCreateActorFrom(const FAssetData& AssetData, FText& OutErrorMsg) { if (AssetData.IsValid() && AssetData.GetClass()->IsChildOf(UBasicVolume::StaticClass())) { return true; } else { OutErrorMsg = NSLOCTEXT("Voreeal", "CanCreateActorFrom_NoVoxelVolume", "No voxel volume was specified."); return false; } }
static bool CanCreateAnimBlueprint(const FAssetData& Skeleton, UClass const * ParentClass) { if (Skeleton.IsValid() && ParentClass != NULL) { if (UAnimBlueprintGeneratedClass const * GeneratedParent = Cast<const UAnimBlueprintGeneratedClass>(ParentClass)) { if (Skeleton.GetExportTextName() != FAssetData(GeneratedParent->GetTargetSkeleton()).GetExportTextName()) { return false; } } } return true; }
//------------------------------------------------------------------------------ static void BlueprintActionDatabaseImpl::OnAssetRemoved(FAssetData const& AssetInfo) { FBlueprintActionDatabase& ActionDatabase = FBlueprintActionDatabase::Get(); if (AssetInfo.IsAssetLoaded()) { UObject* AssetObject = AssetInfo.GetAsset(); OnAssetRemoved(AssetObject); } else { ActionDatabase.ClearUnloadedAssetActions(AssetInfo.ObjectPath); } }
void UMatineeTrackAnimControlHelper::OnAddKeyTextEntry(const FAssetData& AssetData, IMatineeBase* Matinee, UInterpTrack* Track) { if (EntryMenu.IsValid()) { EntryMenu.Pin()->Dismiss(); } UObject* SelectedObject = AssetData.GetAsset(); if (SelectedObject && SelectedObject->IsA(UAnimSequence::StaticClass())) { KeyframeAddAnimSequence = CastChecked<UAnimSequence>(AssetData.GetAsset()); Matinee->FinishAddKey(Track, true); } }
void SGlobalOpenAssetDialog::OnAssetSelectedFromPicker(const FAssetData& AssetData) { if (UObject* ObjectToEdit = AssetData.GetAsset()) { FAssetEditorManager::Get().OpenEditorForAsset(ObjectToEdit); } }
bool FPersonaAssetFamily::IsAssetCompatible(const FAssetData& InAssetData) const { UClass* Class = InAssetData.GetClass(); if (Class) { if (Class->IsChildOf<USkeleton>()) { return FAssetData(Skeleton.Get()) == InAssetData; } else if (Class->IsChildOf<UAnimationAsset>() || Class->IsChildOf<USkeletalMesh>()) { const FString* TargetSkeleton = InAssetData.TagsAndValues.Find("Skeleton"); if (TargetSkeleton) { return *TargetSkeleton == FAssetData(Skeleton.Get()).GetExportTextName(); } } else if (Class->IsChildOf<UAnimBlueprint>()) { const FString* TargetSkeleton = InAssetData.TagsAndValues.Find("TargetSkeleton"); if (TargetSkeleton) { return *TargetSkeleton == FAssetData(Skeleton.Get()).GetExportTextName(); } } } return false; }
void FActorFactoryAssetProxy::GenerateActorFactoryMenuItems( const FAssetData& AssetData, TArray<FMenuItem>* OutMenuItems, bool ExcludeStandAloneFactories ) { FText UnusedErrorMessage; const FAssetData NoAssetData; for ( int32 FactoryIdx = 0; FactoryIdx < GEditor->ActorFactories.Num(); FactoryIdx++ ) { UActorFactory* Factory = GEditor->ActorFactories[FactoryIdx]; const bool FactoryWorksWithoutAsset = Factory->CanCreateActorFrom( NoAssetData, UnusedErrorMessage ); const bool FactoryWorksWithAsset = AssetData.IsValid() && Factory->CanCreateActorFrom( AssetData, UnusedErrorMessage ); const bool FactoryWorks = FactoryWorksWithAsset || FactoryWorksWithoutAsset; if ( FactoryWorks ) { FMenuItem MenuItem = FMenuItem( Factory, NoAssetData ); if ( FactoryWorksWithAsset ) { MenuItem = FMenuItem( Factory, AssetData ); } if ( FactoryWorksWithAsset || ( !ExcludeStandAloneFactories && FactoryWorksWithoutAsset ) ) { OutMenuItems->Add( MenuItem ); } } } }
virtual UEdGraphNode* PerformAction(class UEdGraph* ParentGraph, UEdGraphPin* FromPin, const FVector2D Location, bool bSelectNewNode = true) override { UAnimGraphNode_SequencePlayer* SpawnedNode = CastChecked<UAnimGraphNode_SequencePlayer>(FEdGraphSchemaAction_K2NewNode::PerformAction(ParentGraph, FromPin, Location, bSelectNewNode)); SpawnedNode->Node.Sequence = Cast<UAnimSequence>(AssetInfo.GetAsset()); return SpawnedNode; }
//------------------------------------------------------------------------------ static void BlueprintActionDatabaseImpl::OnAssetAdded(FAssetData const& NewAssetInfo) { if (NewAssetInfo.IsAssetLoaded()) { UObject* AssetObject = NewAssetInfo.GetAsset(); if (UBlueprint* NewBlueprint = Cast<UBlueprint>(AssetObject)) { OnBlueprintChanged(NewBlueprint); } else { FBlueprintActionDatabase& ActionDatabase = FBlueprintActionDatabase::Get(); ActionDatabase.RefreshAssetActions(AssetObject); } } }
void FSlateFontInfoStructCustomization::OnFontChanged(const FAssetData& InAssetData) { const UFont* const FontAsset = Cast<const UFont>(InAssetData.GetAsset()); const FName FirstFontName = (FontAsset && FontAsset->CompositeFont.DefaultTypeface.Fonts.Num()) ? FontAsset->CompositeFont.DefaultTypeface.Fonts[0].Name : NAME_None; TArray<FSlateFontInfo*> SlateFontInfoStructs = GetFontInfoBeingEdited(); for(FSlateFontInfo* FontInfo : SlateFontInfoStructs) { // The font has been updated in the editor, so clear the non-UObject pointer so that the two don't conflict FontInfo->CompositeFont.Reset(); // We've changed (or cleared) the font asset, so make sure and update the typeface entry name being used by the font info TypefaceFontNameProperty->SetValue(FirstFontName); } if(!FontAsset) { const FString PropertyPath = FontObjectProperty->GeneratePathToProperty(); TArray<UObject*> PropertyOuterObjects; FontObjectProperty->GetOuterObjects(PropertyOuterObjects); for(const UObject* OuterObject : PropertyOuterObjects) { UE_LOG(LogSlate, Warning, TEXT("FSlateFontInfo property '%s' on object '%s' was set to use a null UFont. Slate will be forced to use the fallback font path which may be slower."), *PropertyPath, *OuterObject->GetPathName()); } } }
bool UTerrainSplineActorFactory::CanCreateActorFrom(const FAssetData& AssetData, FText& OutErrorMsg) { if (GetDefault<UPaperRuntimeSettings>()->bEnableTerrainSplineEditing) { if (AssetData.IsValid() && AssetData.GetClass()->IsChildOf(UPaperTerrainMaterial::StaticClass())) { return true; } else { return Super::CanCreateActorFrom(AssetData, OutErrorMsg); } } else { return false; } }
//------------------------------------------------------------------------------ static void BlueprintActionDatabaseImpl::OnAssetRenamed(FAssetData const& AssetInfo, const FString& InOldName) { FBlueprintActionDatabase& ActionDatabase = FBlueprintActionDatabase::Get(); if (!AssetInfo.IsAssetLoaded()) { ActionDatabase.MoveUnloadedAssetActions(*InOldName, AssetInfo.ObjectPath); } }
bool SPropertyEditorAsset::CanSetBasedOnCustomClasses( const FAssetData& InAssetData ) const { bool bAllowedToSetBasedOnFilter = true; if( InAssetData.IsValid() && CustomClassFilters.Num() > 0 ) { bAllowedToSetBasedOnFilter = false; UClass* AssetClass = InAssetData.GetClass(); for( const UClass* AllowedClass : CustomClassFilters ) { if( AssetClass->IsChildOf( AllowedClass ) ) { bAllowedToSetBasedOnFilter = true; break; } } } return bAllowedToSetBasedOnFilter; }
void SAssetDialog::OnAssetSelected(const FAssetData& AssetData) { CurrentlySelectedAssets = GetCurrentSelectionDelegate.Execute(); if ( AssetData.IsValid() ) { SetCurrentlySelectedPath(AssetData.PackagePath.ToString()); SetCurrentlyEnteredAssetName(AssetData.AssetName.ToString()); } }
END_SLATE_FUNCTION_BUILD_OPTIMIZATION void SReflectorTreeWidgetItem::HandleHyperlinkNavigate() { FAssetData AssetData = WidgetInfo->GetWidgetAssetData(); if ( AssetData.IsValid() ) { if ( OnAccessAsset.IsBound() ) { AssetData.GetPackage(); OnAccessAsset.Execute(AssetData.GetAsset()); return; } } if ( OnAccessSourceCode.IsBound() ) { OnAccessSourceCode.Execute(GetWidgetFile(), GetWidgetLineNumber(), 0); } }
bool SPropertyEditorAsset::CanSetBasedOnCustomClasses( const FAssetData& InAssetData ) const { bool bAllowedToSetBasedOnFilter = true; if( InAssetData.IsValid() && CustomClassFilters.Num() > 0 ) { bAllowedToSetBasedOnFilter = false; UClass* AssetClass = InAssetData.GetClass(); for( const UClass* AllowedClass : CustomClassFilters ) { const bool bAllowedClassIsInterface = AllowedClass->HasAnyClassFlags(CLASS_Interface); if( AssetClass->IsChildOf( AllowedClass ) || (bAllowedClassIsInterface && AssetClass->ImplementsInterface(AllowedClass)) ) { bAllowedToSetBasedOnFilter = true; break; } } } return bAllowedToSetBasedOnFilter; }
void UMatineeTrackAnimControlHelper::OnAddKeyTextEntry(const FAssetData& AssetData, IMatineeBase* Matinee, UInterpTrack* Track) { if( EntryPopupWindow.IsValid() ) { EntryPopupWindow.Pin()->RequestDestroyWindow(); } KeyframeAddAnimSequence = CastChecked<UAnimSequence>(AssetData.GetAsset()); Matinee->FinishAddKey(Track,true); }
void SSpriteList::OnSpriteDoubleClicked(const FAssetData& AssetData) { TSharedPtr<FSpriteEditor> SpriteEditor = SpriteEditorPtr.Pin(); if (SpriteEditor.IsValid()) { if (UPaperSprite* NewSpriteToEdit = Cast<UPaperSprite>(AssetData.GetAsset())) { SpriteEditor->SetSpriteBeingEdited(NewSpriteToEdit); } } }
TArray<FAssetData> ExtractAssetDataFromDrag(const TSharedPtr<FDragDropOperation>& Operation) { TArray<FAssetData> DroppedAssetData; if (!Operation.IsValid()) { return DroppedAssetData; } if (Operation->IsOfType<FExternalDragOperation>()) { TSharedPtr<FExternalDragOperation> DragDropOp = StaticCastSharedPtr<FExternalDragOperation>(Operation); if ( DragDropOp->HasText() ) { TArray<FString> DroppedAssetStrings; const TCHAR AssetDelimiter[] = { AssetMarshalDefs::AssetDelimiter, TEXT('\0') }; DragDropOp->GetText().ParseIntoArray(DroppedAssetStrings, AssetDelimiter, true); FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry")); IAssetRegistry& AssetRegistry = AssetRegistryModule.Get(); for (int Index = 0; Index < DroppedAssetStrings.Num(); Index++) { // Truncate each string so that it doesn't exceed the maximum allowed length of characters to be converted to an FName FString TruncatedString = DroppedAssetStrings[ Index ].Left( NAME_SIZE ); FAssetData AssetData = AssetRegistry.GetAssetByObjectPath( FName( *TruncatedString ) ); if ( AssetData.IsValid() ) { DroppedAssetData.Add( AssetData ); } } } } else if (Operation->IsOfType<FAssetDragDropOp>()) { TSharedPtr<FAssetDragDropOp> DragDropOp = StaticCastSharedPtr<FAssetDragDropOp>( Operation ); DroppedAssetData.Append( DragDropOp->AssetData ); } return DroppedAssetData; }
//------------------------------------------------------------------------------ bool FBlueprintActionDatabaseRegistrar::AddBlueprintAction(FAssetData const& AssetDataOwner, UBlueprintNodeSpawner* NodeSpawner) { bool bReturnResult = false; // @TODO: assert that AddBlueprintAction(UBlueprintNodeSpawner* NodeSpawner) // wouldn't come up with a different key (besides GeneratingClass) if(AssetDataOwner.IsAssetLoaded()) { bReturnResult = AddBlueprintAction(AssetDataOwner.GetAsset(), NodeSpawner); } else { bReturnResult = AddBlueprintAction(NodeSpawner->NodeClass, NodeSpawner); if(bReturnResult) { TArray<UBlueprintNodeSpawner*>& ActionList = UnloadedActionDatabase.FindOrAdd(AssetDataOwner.ObjectPath); ActionList.Add(NodeSpawner); } } return bReturnResult; }
void FPersonaAssetFamily::RecordAssetOpened(const FAssetData& InAssetData) { if (IsAssetCompatible(InAssetData)) { UClass* Class = InAssetData.GetClass(); if (Class) { if (Class->IsChildOf<USkeleton>()) { Skeleton = Cast<USkeleton>(InAssetData.GetAsset()); } else if (Class->IsChildOf<UAnimationAsset>()) { AnimationAsset = Cast<UAnimationAsset>(InAssetData.GetAsset()); } else if (Class->IsChildOf<USkeletalMesh>()) { Mesh = Cast<USkeletalMesh>(InAssetData.GetAsset()); } else if (Class->IsChildOf<UAnimBlueprint>()) { AnimBlueprint = Cast<UAnimBlueprint>(InAssetData.GetAsset()); } } OnAssetOpened.Broadcast(InAssetData.GetAsset()); } }
TArray<FAssetData> ExtractAssetDataFromDrag(const TSharedPtr<FDragDropOperation>& Operation) { TArray<FAssetData> DroppedAssetData; if (!Operation.IsValid()) { return DroppedAssetData; } if (Operation->IsOfType<FExternalDragOperation>()) { TSharedPtr<FExternalDragOperation> DragDropOp = StaticCastSharedPtr<FExternalDragOperation>(Operation); if ( DragDropOp->HasText() ) { TArray<FString> DroppedAssetStrings; const TCHAR AssetDelimiter[] = { AssetMarshalDefs::AssetDelimiter, TEXT('\0') }; DragDropOp->GetText().ParseIntoArray(DroppedAssetStrings, AssetDelimiter, true); FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry")); IAssetRegistry& AssetRegistry = AssetRegistryModule.Get(); for (int Index = 0; Index < DroppedAssetStrings.Num(); Index++) { FAssetData AssetData = AssetRegistry.GetAssetByObjectPath( *DroppedAssetStrings[ Index ] ); if ( AssetData.IsValid() ) { DroppedAssetData.Add( AssetData ); } } } } else if (Operation->IsOfType<FAssetDragDropOp>()) { TSharedPtr<FAssetDragDropOp> DragDropOp = StaticCastSharedPtr<FAssetDragDropOp>( Operation ); DroppedAssetData.Append( DragDropOp->AssetData ); } return DroppedAssetData; }
void SFlipbookKeyframeWidget::OnAssetSelected(const FAssetData& AssetData) { if (UPaperFlipbook* Flipbook = FlipbookBeingEdited.Get()) { FScopedFlipbookMutator EditLock(Flipbook); if (EditLock.KeyFrames.IsValidIndex(FrameIndex)) { UPaperSprite* NewSprite = Cast<UPaperSprite>(AssetData.GetAsset()); EditLock.KeyFrames[FrameIndex].Sprite = NewSprite; } } }
bool FStringAssetReferenceCustomization::OnShouldFilterAsset( const FAssetData& InAssetData ) const { // Only bound if we have classes to filter on, so we don't need to test for an empty array here UClass* const AssetClass = InAssetData.GetClass(); for(auto It = CustomClassFilters.CreateConstIterator(); It; ++It) { UClass* const FilterClass = *It; const bool bMatchesFilter = (bExactClass) ? AssetClass == FilterClass : AssetClass->IsChildOf(FilterClass); if(bMatchesFilter) { return false; } } return true; }
void FCollectionAssetRegistryBridge::OnAssetRemoved(const FAssetData& AssetData) { FCollectionManagerModule& CollectionManagerModule = FCollectionManagerModule::GetModule(); if (AssetData.IsRedirector()) { // Notify the collections manager that a redirector has been removed // This will attempt to re-save any collections that still have a reference to this redirector in their on-disk collection data CollectionManagerModule.Get().HandleRedirectorDeleted(AssetData.ObjectPath); } else { // Notify the collections manager that an asset has been removed CollectionManagerModule.Get().HandleObjectDeleted(AssetData.ObjectPath); } }
void FPrimaryAssetIdCustomization::OnSetObject(const FAssetData& AssetData) { UAssetManager& Manager = UAssetManager::Get(); if (StructPropertyHandle.IsValid() && StructPropertyHandle->IsValidHandle()) { FPrimaryAssetId AssetId; if (AssetData.IsValid()) { AssetId = Manager.GetPrimaryAssetIdForData(AssetData); ensure(AssetId.IsValid()); } StructPropertyHandle->SetValueFromFormattedString(AssetId.ToString()); } }
bool FAssetDeleteModel::CanReplaceReferencesWith( const FAssetData& InAssetData ) const { // First make sure that it's not an object we're preparing to delete if ( IsAssetInPendingDeletes( InAssetData.PackageName ) ) { return true; } const UClass* FirstPendingDelete = PendingDeletes[0]->GetObject()->GetClass(); const UClass* AssetDataClass = InAssetData.GetClass(); // If the class isn't loaded we can't compare them, so just return true that we'll be // filtering it from the list. if ( AssetDataClass == nullptr ) { return true; } // Only show objects that are of replaceable because their classes are compatible. return !ObjectTools::AreClassesInterchangeable( FirstPendingDelete, AssetDataClass ); }