本文整理汇总了C#中SiliconStudio.Assets.Package.GetDistinctAssetFolderPaths方法的典型用法代码示例。如果您正苦于以下问题:C# Package.GetDistinctAssetFolderPaths方法的具体用法?C# Package.GetDistinctAssetFolderPaths怎么用?C# Package.GetDistinctAssetFolderPaths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SiliconStudio.Assets.Package
的用法示例。
在下文中一共展示了Package.GetDistinctAssetFolderPaths方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ListAssetFiles
private static List<Tuple<UFile, UDirectory>> ListAssetFiles(ILogger log, Package package, CancellationToken? cancelToken)
{
var listFiles = new List<Tuple<UFile, UDirectory>>();
// TODO Check how to handle refresh correctly as a public API
if (package.RootDirectory == null)
{
throw new InvalidOperationException("Package RootDirectory is null");
}
if (!Directory.Exists(package.RootDirectory))
{
throw new InvalidOperationException("Package RootDirectory [{0}] does not exist".ToFormat(package.RootDirectory));
}
// Iterate on each source folders
foreach (var sourceFolder in package.GetDistinctAssetFolderPaths())
{
// Lookup all files
foreach (var directory in FileUtility.EnumerateDirectories(sourceFolder, SearchDirection.Down))
{
var files = directory.GetFiles();
foreach (var filePath in files)
{
// Don't load package via this method
if (filePath.FullName.EndsWith(PackageFileExtension))
{
continue;
}
// Make an absolute path from the root of this package
var fileUPath = new UFile(filePath.FullName);
if (fileUPath.GetFileExtension() == null)
{
continue;
}
// If this kind of file an asset file?
if (!AssetRegistry.IsAssetFileExtension(fileUPath.GetFileExtension()))
{
continue;
}
listFiles.Add(new Tuple<UFile, UDirectory>(fileUPath, sourceFolder));
}
}
}
return listFiles;
}
示例2: ListAssetFiles
public static List<PackageLoadingAssetFile> ListAssetFiles(ILogger log, Package package, CancellationToken? cancelToken)
{
var listFiles = new List<PackageLoadingAssetFile>();
// TODO Check how to handle refresh correctly as a public API
if (package.RootDirectory == null)
{
throw new InvalidOperationException("Package RootDirectory is null");
}
if (!Directory.Exists(package.RootDirectory))
{
return listFiles;
}
var sharedProfile = package.Profiles.FindSharedProfile();
var hasProject = sharedProfile != null && sharedProfile.ProjectReferences.Count > 0;
// Iterate on each source folders
foreach (var sourceFolder in package.GetDistinctAssetFolderPaths())
{
// Lookup all files
foreach (var directory in FileUtility.EnumerateDirectories(sourceFolder, SearchDirection.Down))
{
var files = directory.GetFiles();
foreach (var filePath in files)
{
// Don't load package via this method
if (filePath.FullName.EndsWith(PackageFileExtension))
{
continue;
}
// Make an absolute path from the root of this package
var fileUPath = new UFile(filePath.FullName);
if (fileUPath.GetFileExtension() == null)
{
continue;
}
// If this kind of file an asset file?
var ext = fileUPath.GetFileExtension();
//make sure to add default shaders in this case, since we don't have a csproj for them
if (AssetRegistry.IsProjectCodeGeneratorAssetFileExtension(ext) && !hasProject)
{
listFiles.Add(new PackageLoadingAssetFile(fileUPath, sourceFolder));
continue;
}
if (!AssetRegistry.IsAssetFileExtension(ext) || AssetRegistry.IsProjectSourceCodeAssetFileExtension(ext)) //project source code assets follow the csproj pipeline
{
continue;
}
listFiles.Add(new PackageLoadingAssetFile(fileUPath, sourceFolder));
}
}
}
//find also assets in the csproj
FindCodeAssetsInProject(listFiles, package);
return listFiles;
}