本文整理匯總了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;
}