本文整理汇总了C++中TOptional::GetSourceFileData方法的典型用法代码示例。如果您正苦于以下问题:C++ TOptional::GetSourceFileData方法的具体用法?C++ TOptional::GetSourceFileData怎么用?C++ TOptional::GetSourceFileData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TOptional
的用法示例。
在下文中一共展示了TOptional::GetSourceFileData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleOnAssetRenamed
void FAssetSourceFilenameCache::HandleOnAssetRenamed(const FAssetData& AssetData, const FString& OldPath)
{
TOptional<FAssetImportInfo> ImportData = ExtractAssetImportInfo(AssetData.TagsAndValues);
if (ImportData.IsSet())
{
FName OldPathName = *OldPath;
for (auto& SourceFile : ImportData->GetSourceFileData())
{
FString CleanFilename = FPaths::GetCleanFilename(SourceFile.RelativeFilename);
if (auto* Objects = SourceFileToObjectPathCache.Find(CleanFilename))
{
Objects->Remove(OldPathName);
if (Objects->Num() == 0)
{
SourceFileToObjectPathCache.Remove(CleanFilename);
}
}
SourceFileToObjectPathCache.FindOrAdd(CleanFilename).Add(AssetData.ObjectPath);
}
}
AssetRenamedEvent.Broadcast(AssetData, OldPath);
}
示例2: HandleOnAssetAdded
void FAssetSourceFilenameCache::HandleOnAssetAdded(const FAssetData& AssetData)
{
TOptional<FAssetImportInfo> ImportData = ExtractAssetImportInfo(AssetData.TagsAndValues);
if (ImportData.IsSet())
{
for (const auto& SourceFile : ImportData->GetSourceFileData())
{
SourceFileToObjectPathCache.FindOrAdd(FPaths::GetCleanFilename(SourceFile.RelativeFilename)).Add(AssetData.ObjectPath);
}
}
}
示例3: HandleOnAssetRemoved
void FAssetSourceFilenameCache::HandleOnAssetRemoved(const FAssetData& AssetData)
{
TOptional<FAssetImportInfo> ImportData = ExtractAssetImportInfo(AssetData.TagsAndValues);
if (ImportData.IsSet())
{
for (auto& SourceFile : ImportData->GetSourceFileData())
{
FString CleanFilename = FPaths::GetCleanFilename(SourceFile.RelativeFilename);
if (auto* Objects = SourceFileToObjectPathCache.Find(CleanFilename))
{
Objects->Remove(AssetData.ObjectPath);
if (Objects->Num() == 0)
{
SourceFileToObjectPathCache.Remove(CleanFilename);
}
}
}
}
}
示例4: ExtractAssetImportInfo
TArray<FAssetData> FAssetSourceFilenameCache::GetAssetsPertainingToFile(const IAssetRegistry& Registry, const FString& AbsoluteFilename) const
{
TArray<FAssetData> Assets;
if (const auto* ObjectPaths = SourceFileToObjectPathCache.Find(FPaths::GetCleanFilename(AbsoluteFilename)))
{
for (const FName& Path : *ObjectPaths)
{
FAssetData Asset = Registry.GetAssetByObjectPath(Path);
TOptional<FAssetImportInfo> ImportInfo = ExtractAssetImportInfo(Asset.TagsAndValues);
if (ImportInfo.IsSet())
{
auto AssetPackagePath = FPackageName::LongPackageNameToFilename(Asset.PackagePath.ToString() / TEXT(""));
// Attempt to find the matching source filename in the list of imported sorce files (generally there are only one of these)
const bool bWasImportedFromFile = ImportInfo->GetSourceFileData().ContainsByPredicate([&](const FAssetImportInfo::FSourceFile& File){
if (AbsoluteFilename == FPaths::ConvertRelativePathToFull(AssetPackagePath / File.RelativeFilename) ||
AbsoluteFilename == FPaths::ConvertRelativePathToFull(File.RelativeFilename))
{
return true;
}
return false;
});
if (bWasImportedFromFile)
{
Assets.Emplace();
Swap(Asset, Assets[Assets.Num() - 1]);
}
}
}
}
return Assets;
}