本文整理汇总了C++中UPaperSprite::GetOutermost方法的典型用法代码示例。如果您正苦于以下问题:C++ UPaperSprite::GetOutermost方法的具体用法?C++ UPaperSprite::GetOutermost怎么用?C++ UPaperSprite::GetOutermost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UPaperSprite
的用法示例。
在下文中一共展示了UPaperSprite::GetOutermost方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateNewSprite
// Create a new sprite and return this sprite. The sprite editor will now be editing this new sprite
// Returns nullptr if failed
UPaperSprite* FSpriteEditorViewportClient::CreateNewSprite(const FIntPoint& TopLeft, const FIntPoint& Dimensions)
{
FAssetToolsModule& AssetToolsModule = FModuleManager::Get().LoadModuleChecked<FAssetToolsModule>("AssetTools");
FContentBrowserModule& ContentBrowserModule = FModuleManager::LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
UPaperSprite* CurrentSprite = GetSpriteBeingEdited();
UPaperSprite* CreatedSprite = nullptr;
// Create the factory used to generate the sprite
UPaperSpriteFactory* SpriteFactory = NewObject<UPaperSpriteFactory>();
SpriteFactory->InitialTexture = CurrentSprite->SourceTexture;
SpriteFactory->bUseSourceRegion = true;
SpriteFactory->InitialSourceUV = TopLeft;
SpriteFactory->InitialSourceDimension = Dimensions;
// Get a unique name for the sprite
FString Name, PackageName;
AssetToolsModule.Get().CreateUniqueAssetName(CurrentSprite->GetOutermost()->GetName(), TEXT(""), /*out*/ PackageName, /*out*/ Name);
const FString PackagePath = FPackageName::GetLongPackagePath(PackageName);
if (UObject* NewAsset = AssetToolsModule.Get().CreateAsset(Name, PackagePath, UPaperSprite::StaticClass(), SpriteFactory))
{
TArray<UObject*> Objects;
Objects.Add(NewAsset);
ContentBrowserModule.Get().SyncBrowserToAssets(Objects);
UPaperSprite* NewSprite = Cast<UPaperSprite>(NewAsset);
if (SpriteEditorPtr.IsValid() && (NewSprite != nullptr))
{
SpriteEditorPtr.Pin()->SetSpriteBeingEdited(NewSprite);
}
CreatedSprite = NewSprite;
}
return CreatedSprite;
}