void FAssetEditorToolkit::FillDefaultAssetMenuCommands( FMenuBuilder& MenuBuilder )
{
	// Commands we only want to be accessible when editing an asset should go here 
	if( IsActuallyAnAsset() )
	{
		MenuBuilder.AddMenuEntry( FGlobalEditorCommonCommands::Get().FindInContentBrowser, "FindInContentBrowser", LOCTEXT("FindInContentBrowser", "Find in Content Browser...") );
		MenuBuilder.AddMenuEntry( FGlobalEditorCommonCommands::Get().ViewReferences);
		MenuBuilder.AddMenuEntry( FGlobalEditorCommonCommands::Get().ViewSizeMap);

		// Add a reimport menu entry for each supported editable object
		for( auto ObjectIter = EditingObjects.CreateConstIterator(); ObjectIter; ++ObjectIter )
		{
			const auto EditingObject = *ObjectIter;
			if( EditingObject != NULL && EditingObject->IsAsset() )
			{
				if ( CanReimport( EditingObject ) )
				{
					FFormatNamedArguments LabelArguments;
					LabelArguments.Add(TEXT("Name"), FText::FromString( EditingObject->GetName() ));
					const FText LabelText = FText::Format( LOCTEXT("Reimport_Label", "Reimport {Name}..."), LabelArguments );
					FFormatNamedArguments ToolTipArguments;
					ToolTipArguments.Add(TEXT("Type"), FText::FromString( EditingObject->GetClass()->GetName() ));
					const FText ToolTipText = FText::Format( LOCTEXT("Reimport_ToolTip", "Reimports this {Type}"), ToolTipArguments );
					const FName IconName = TEXT( "AssetEditor.Reimport" );
					FUIAction UIAction;
					UIAction.ExecuteAction.BindRaw( this, &FAssetEditorToolkit::Reimport_Execute, EditingObject );
					MenuBuilder.AddMenuEntry( LabelText, ToolTipText, FSlateIcon(FEditorStyle::GetStyleSetName(), IconName), UIAction );
				}
			}
		}		
	}
}
bool FAssetEditorToolkit::IsActuallyAnAsset() const
{
	// Don't allow user to perform certain actions on objects that aren't actually assets (e.g. Level Script blueprint objects)
	bool bIsActuallyAnAsset = false;
	for( auto ObjectIter = GetObjectsCurrentlyBeingEdited()->CreateConstIterator(); !bIsActuallyAnAsset && ObjectIter; ++ObjectIter )
	{
		const auto ObjectBeingEdited = *ObjectIter;
		bIsActuallyAnAsset |= ObjectBeingEdited != NULL && ObjectBeingEdited->IsAsset();
	}
	return bIsActuallyAnAsset;
}
void USoundBank::PostInitProperties()
{
	Super::PostInitProperties();
	if ( IsAsset() )
	{
		if ( SoundBankID.IsEmpty() )
		{
			GetName( SoundBankID );
		}
	}
}
void FAssetEditorToolkit::FindInContentBrowser_Execute()
{
	if( ensure( EditingObjects.Num() > 0 ) )
	{
		TArray< UObject* > ObjectsToSyncTo;

		for( auto ObjectIter = EditingObjects.CreateConstIterator(); ObjectIter; ++ObjectIter )
		{
			// Don't allow user to perform certain actions on objects that aren't actually assets (e.g. Level Script blueprint objects)
			const auto EditingObject = *ObjectIter;
			if( EditingObject != NULL && EditingObject->IsAsset() )
			{
				ObjectsToSyncTo.Add( EditingObject );
			}
		}

		GEditor->SyncBrowserToObjects( ObjectsToSyncTo );
	}
}
void FAssetEditorToolkit::SaveAsset_Execute()
{
	if( ensure( EditingObjects.Num() > 0 ) )
	{
		TArray< UPackage* > PackagesToSave;

		for( auto ObjectIter = EditingObjects.CreateConstIterator(); ObjectIter; ++ObjectIter )
		{
			// Don't allow user to perform certain actions on objects that aren't actually assets (e.g. Level Script blueprint objects)
			const auto EditingObject = *ObjectIter;
			if( EditingObject != NULL && EditingObject->IsAsset() )
			{
				PackagesToSave.Add( EditingObject->GetOutermost() );
			}
		}

		FEditorFileUtils::PromptForCheckoutAndSave( PackagesToSave, bCheckDirtyOnAssetSave, /*bPromptToSave=*/ false );
	}
}
Exemple #6
0
ptree AnimaNode::GetObjectTree(bool saveName) const
{
	ptree tree;

	if (saveName)
		tree.add("AnimaNode.Name", GetName());

	AnimaString materialName = "";
	if (_material != nullptr)
		materialName = _material->GetName();
	else
		materialName = _materialName;

	tree.add("AnimaNode.IsAsset", IsAsset());
	tree.add("AnimaNode.Material", materialName);
	tree.add("AnimaNode.AnimationNodeName", _animationNodeName);

	ptree geometriesTree;
	AInt count = _geometries.GetSize();
	for (AInt i = 0; i < count; i++)
		geometriesTree.add("Geometry", _geometries[i]->GetName());
	tree.add_child("AnimaNode.Geometries", geometriesTree);

	ptree geometriesBonesInfoTree;
	count = _geometriesBonesInfo.GetSize();
	for (AInt i = 0; i < count; i++)
		geometriesBonesInfoTree.add_child("BoneInfo", _geometriesBonesInfo[i]->GetObjectTree());
	tree.add_child("AnimaNode.GeometriesBonesInfo", geometriesBonesInfoTree);

	ptree animationsTree;
	for (auto& animation : _animations)
		animationsTree.add("Animation", animation->GetName());
	tree.add_child("AnimaNode.Animations", animationsTree);

	tree.add_child("AnimaNode.SceneObject", AnimaSceneObject::GetObjectTree(false));

	return tree;
}