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());
	}
}
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);
	}
}
	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;
	}
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 FBlueprintActionDatabaseRegistrar::IsOpenForRegistration(FAssetData const& AssetKey)
{
	UObject const* OwnerKey = GeneratingClass;
	if (AssetKey.IsAssetLoaded())
	{
		OwnerKey = AssetKey.GetAsset();
	}
	return IsOpenForRegistration(OwnerKey);
}
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);
}
Example #8
0
void SSpriteList::OnSpriteDoubleClicked(const FAssetData& AssetData)
{
	TSharedPtr<FSpriteEditor> SpriteEditor = SpriteEditorPtr.Pin();
	if (SpriteEditor.IsValid())
	{
		if (UPaperSprite* NewSpriteToEdit = Cast<UPaperSprite>(AssetData.GetAsset()))
		{
			SpriteEditor->SetSpriteBeingEdited(NewSpriteToEdit);
		}
	}
}
//------------------------------------------------------------------------------
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 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;
		}
	}
}
//------------------------------------------------------------------------------
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);
		}
	}
}
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 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;
}
Example #14
0
bool FAssetDeleteModel::DoReplaceReferences(const FAssetData& ReplaceReferencesWith )
{
	if ( !CanReplaceReferences() )
	{
		return false;
	}

	// Find which object the user has elected to be the "object to consolidate to"
	UObject* ObjectToConsolidateTo = ReplaceReferencesWith.GetAsset();
	check( ObjectToConsolidateTo );

	TArray<UObject*> FinalConsolidationObjects;
	for ( TSharedPtr< FPendingDelete >& PendingDelete : PendingDeletes )
	{
		FinalConsolidationObjects.Add(PendingDelete->GetObject());
	}

	// The consolidation action clears the array, so we need to save the count.
	int32 ObjectsBeingDeletedCount = FinalConsolidationObjects.Num();

	// Perform the object consolidation
	bool bShowDeleteConfirmation = false;
	ObjectTools::FConsolidationResults ConsResults = ObjectTools::ConsolidateObjects( ObjectToConsolidateTo, FinalConsolidationObjects, bShowDeleteConfirmation );

	// If the consolidation went off successfully with no failed objects, prompt the user to checkout/save the packages dirtied by the operation
	if ( ConsResults.DirtiedPackages.Num() > 0 && ConsResults.FailedConsolidationObjs.Num() == 0)
	{
		FEditorFileUtils::PromptForCheckoutAndSave( ConsResults.DirtiedPackages, false, true );
	}
	// If the consolidation resulted in failed (partially consolidated) objects, do not save, and inform the user no save attempt was made
	else if ( ConsResults.FailedConsolidationObjs.Num() > 0)
	{
		//DisplayMessage( true, LOCTEXT( "Consolidate_WarningPartial", "Not all objects could be consolidated, no save has occurred" ).ToString() );
	}

	ObjectsDeleted = ObjectsBeingDeletedCount - ( ConsResults.FailedConsolidationObjs.Num() + ConsResults.InvalidConsolidationObjs.Num() );

	return true;
}
Example #15
0
bool UMaterialGraphSchema::HasCompatibleConnection(const FAssetData& FunctionAssetData, uint32 TestType, EEdGraphPinDirection TestDirection) const
{
	if (TestType != 0)
	{
		const FString* CombinedInputTagValue = FunctionAssetData.TagsAndValues.Find(GET_MEMBER_NAME_CHECKED(UMaterialFunction, CombinedInputTypes));
		const FString* CombinedOutputTagValue = FunctionAssetData.TagsAndValues.Find(GET_MEMBER_NAME_CHECKED(UMaterialFunction, CombinedOutputTypes));
		uint32 CombinedInputTypes = CombinedInputTagValue ? FCString::Atoi(**CombinedInputTagValue) : 0;
		uint32 CombinedOutputTypes = CombinedOutputTagValue ? FCString::Atoi(**CombinedOutputTagValue) : 0;

		if (CombinedOutputTypes == 0)
		{
			// Need to load function to build combined output types
			UMaterialFunction* MaterialFunction = Cast<UMaterialFunction>(FunctionAssetData.GetAsset());
			if (MaterialFunction != nullptr)
			{
				CombinedInputTypes = MaterialFunction->CombinedInputTypes;
				CombinedOutputTypes = MaterialFunction->CombinedOutputTypes;
			}
		}

		if (TestDirection == EGPD_Output)
		{
			if (CanConnectMaterialValueTypes(CombinedInputTypes, TestType))
			{
				return true;
			}
		}
		else
		{
			if (CanConnectMaterialValueTypes(TestType, CombinedOutputTypes))
			{
				return true;
			}
		}
	}

	return false;
}
Example #16
0
void FPropertyEditor::OnAssetSelected( const FAssetData& AssetData )
{
	// Set the object found from the asset picker
	GetPropertyHandle()->SetValueFromFormattedString( AssetData.IsValid() ? AssetData.GetAsset()->GetPathName() : TEXT("None") );
}
void UAnimSequenceFactory::OnTargetSkeletonSelected(const FAssetData& SelectedAsset)
{
	TargetSkeleton = Cast<USkeleton>(SelectedAsset.GetAsset());
	PickerWindow->RequestDestroyWindow();
}
Example #18
0
void SContentReference::OnAssetSelectedFromPicker(const FAssetData& AssetData)
{
	PickerComboButton->SetIsOpen(false);
	OnSetReference.ExecuteIfBound(AssetData.GetAsset());
}
bool FSlateFontInfoStructCustomization::OnFilterFontAsset(const FAssetData& InAssetData)
{
	// We want to filter font assets that aren't valid to use with Slate/UMG
	return Cast<const UFont>(InAssetData.GetAsset())->FontCacheType != EFontCacheType::Runtime;
}
Example #20
0
void FAutoReimportManager::OnAssetRenamed(const FAssetData& AssetData, const FString& OldPath)
{
	if (bGuardAssetChanges)
	{
		return;
	}

	// This code moves a source content file that reside alongside assets when the assets are renamed. We do this under the following conditions:
	// 	1. The sourcefile is solely referenced from the the asset that has been moved
	//	2. Said asset only references a single file
	//	3. The source file resides in the same folder as the asset
	//
	// Additionally, we rename the source file if it matched the name of the asset before the rename/move.
	//	- If we rename the source file, then we also update the reimport paths for the asset

	TArray<FString> SourceFilesRelativeToOldPath;
	for (const auto& Pair : AssetData.TagsAndValues)
	{
		if (Pair.Key.IsEqual(UObject::SourceFileTagName(), ENameCase::IgnoreCase, false))
		{
			SourceFilesRelativeToOldPath.Add(Pair.Value);
		}
	}

	// We move the file with the asset provided it is the only file referenced, and sits right beside the uasset file
	if (SourceFilesRelativeToOldPath.Num() == 1 && !SourceFilesRelativeToOldPath[0].GetCharArray().ContainsByPredicate([](const TCHAR Char) { return Char == '/' || Char == '\\'; }))
	{
		const FString AbsoluteSrcPath = FPaths::ConvertRelativePathToFull(FPackageName::LongPackageNameToFilename(FPackageName::GetLongPackagePath(OldPath) / TEXT("")));
		const FString AbsoluteDstPath = FPaths::ConvertRelativePathToFull(FPackageName::LongPackageNameToFilename(AssetData.PackagePath.ToString() / TEXT("")));

		const FString OldAssetName = FPackageName::GetLongPackageAssetName(FPackageName::ObjectPathToPackageName(OldPath));
		FString NewFileName = FPaths::GetBaseFilename(SourceFilesRelativeToOldPath[0]);

		bool bRequireReimportPathUpdate = false;
		if (PackageTools::SanitizePackageName(NewFileName) == OldAssetName)
		{
			NewFileName = AssetData.AssetName.ToString();
			bRequireReimportPathUpdate = true;
		}

		const FString SrcFile = AbsoluteSrcPath / SourceFilesRelativeToOldPath[0];
		const FString DstFile = AbsoluteDstPath / NewFileName + TEXT(".") + FPaths::GetExtension(SourceFilesRelativeToOldPath[0]);

		// We can't do this if multiple assets reference the same file. We should be checking for > 1 referencing asset, but the asset registry
		// filter lookup won't return the recently renamed package because it will be Empty by now, so we check for *anything* referencing the asset (assuming that we'll never find *this* asset).
		const IAssetRegistry& Registry = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry").Get();
		if (Utils::FindAssetsPertainingToFile(Registry, SrcFile).Num() > 0)
		{
			return;
		}

		if (!FPlatformFileManager::Get().GetPlatformFile().FileExists(*DstFile) &&
			IFileManager::Get().Move(*DstFile, *SrcFile, false /*bReplace */, false, true /* attributes */, true /* don't retry */))
		{
			IgnoreMovedFile(SrcFile, DstFile);

			if (bRequireReimportPathUpdate)
			{
				TArray<FString> Paths;
				Paths.Add(DstFile);

				// Update the reimport file names
				FReimportManager::Instance()->UpdateReimportPaths(AssetData.GetAsset(), Paths);
			}
		}
	}
}
TSharedPtr<SWidget> FAssetTypeActions_SoundWave::GetThumbnailOverlay(const FAssetData& AssetData) const
{
	TArray<TWeakObjectPtr<USoundBase>> SoundList;
	SoundList.Add(TWeakObjectPtr<USoundBase>((USoundBase*)AssetData.GetAsset()));

	auto OnGetDisplayBrushLambda = [this, SoundList]() -> const FSlateBrush*
	{
		if (IsSoundPlaying(SoundList))
		{
			return FEditorStyle::GetBrush("MediaAsset.AssetActions.Stop");
		}

		return FEditorStyle::GetBrush("MediaAsset.AssetActions.Play");
	};

	auto IsEnabledLambda = [this, SoundList]() -> bool
	{
		return CanExecutePlayCommand(SoundList);
	};

	auto OnClickedLambda = [this, SoundList]() -> FReply
	{
		if (IsSoundPlaying(SoundList))
		{
			ExecuteStopSound(SoundList);
		}
		else
		{
			ExecutePlaySound(SoundList);
		}
		return FReply::Handled();
	};

	auto OnToolTipTextLambda = [this, SoundList]() -> FText
	{
		if (IsSoundPlaying(SoundList))
		{
			return LOCTEXT("Blueprint_StopSoundToolTip", "Stop selected Sound Wave");
		}

		return LOCTEXT("Blueprint_PlaySoundToolTip", "Play selected Sound Wave");
	};

	return SNew(SBox)
		.HAlign(HAlign_Center)
		.VAlign(VAlign_Center)
		.Padding(FMargin(2))
		[
			SNew(SButton)
			.ButtonStyle(FEditorStyle::Get(), "HoverHintOnly")
			.ToolTipText_Lambda(OnToolTipTextLambda)
			.Cursor(EMouseCursor::Default) // The outer widget can specify a DragHand cursor, so we need to override that here
			.ForegroundColor(FSlateColor::UseForeground())		
			.IsEnabled_Lambda(IsEnabledLambda)
			.OnClicked_Lambda(OnClickedLambda)
			[
				SNew(SBox)
				.MinDesiredWidth(16)
				.MinDesiredHeight(16)
				[
					SNew(SImage)
					.Image_Lambda(OnGetDisplayBrushLambda)
				]
			]
		];
}