本文整理汇总了C#中SiliconStudio.Core.IO.UFile类的典型用法代码示例。如果您正苦于以下问题:C# UFile类的具体用法?C# UFile怎么用?C# UFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UFile类属于SiliconStudio.Core.IO命名空间,在下文中一共展示了UFile类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TestUpdateAssetUrl
public void TestUpdateAssetUrl()
{
var projectDir = new UFile(Path.Combine(Environment.CurrentDirectory, "testxk"));
// Create a project with an asset reference a raw file
var project = new Package { FullPath = projectDir };
var assetItem = new AssetItem("test", new AssetObjectTest() { Reference = new AssetReference<AssetObjectTest>(Guid.Empty, "good/location")});
project.Assets.Add(assetItem);
var goodAsset = new AssetObjectTest();
project.Assets.Add(new AssetItem("good/location", goodAsset));
// Add the project to the session to make sure analysis will run correctly
var session = new PackageSession(project);
// Create a session with this project
var analysis = new PackageAnalysis(project,
new PackageAnalysisParameters()
{
IsProcessingAssetReferences = true,
ConvertUPathTo = UPathType.Absolute,
IsProcessingUPaths = true
});
var result = analysis.Run();
Assert.IsFalse(result.HasErrors);
Assert.AreEqual(1, result.Messages.Count);
Assert.IsTrue(result.Messages[0].ToString().Contains("changed"));
var asset = (AssetObjectTest)assetItem.Asset;
Assert.AreEqual(goodAsset.Id, asset.Reference.Id);
Assert.AreEqual("good/location", asset.Reference.Location);
}
开发者ID:cg123,项目名称:xenko,代码行数:31,代码来源:TestAssetReferenceAnalysis.cs
示例2: AssetToImport
/// <summary>
/// Initializes a new instance of the <see cref="AssetToImport"/> class.
/// </summary>
/// <param name="file">The file.</param>
/// <exception cref="System.ArgumentNullException">file</exception>
internal AssetToImport(UFile file)
{
if (file == null) throw new ArgumentNullException("file");
this.file = file;
ByImporters = new List<AssetToImportByImporter>();
Enabled = true;
}
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:12,代码来源:AssetToImport.cs
示例3: GetAbsolutePath
/// <summary>
/// Returns the absolute path on the disk of an <see cref="UFile"/> that is relative to the asset location.
/// </summary>
/// <param name="assetItem">The asset on which is based the relative path.</param>
/// <param name="relativePath">The path relative to the asset path that must be converted to an absolute path.</param>
/// <returns>The absolute path on the disk of the <see cref="relativePath"/> argument.</returns>
/// <exception cref="ArgumentException">The <see cref="relativePath"/> argument is a null or empty <see cref="UFile"/>.</exception>
protected static UFile GetAbsolutePath(AssetItem assetItem, UFile relativePath)
{
if (string.IsNullOrEmpty(relativePath)) throw new ArgumentException("The relativePath argument is null or empty");
var assetDirectory = assetItem.FullPath.GetParent();
var assetSource = UPath.Combine(assetDirectory, relativePath);
return assetSource;
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:14,代码来源:AssetCompilerBase.cs
示例4: ImportScene
public static EntityHierarchyData ImportScene(UFile sourceUrl, EntityGroupAssetBase source, Guid sourceRootEntity)
{
if (source == null) throw new ArgumentNullException("source");
// Extract the scene starting from given root
var newAsset = ExtractSceneClone(source, sourceRootEntity);
// Generate entity mapping
var reverseEntityMapping = new Dictionary<Guid, Guid>();
foreach (var entityDesign in newAsset.Hierarchy.Entities)
{
// Generate new Id
var newEntityId = Guid.NewGuid();
// Update mappings
reverseEntityMapping.Add(entityDesign.Entity.Id, newEntityId);
// Update entity with new id
entityDesign.Entity.Id = newEntityId;
}
// Rewrite entity references
// Should we nullify invalid references?
EntityAnalysis.RemapEntitiesId(newAsset.Hierarchy, reverseEntityMapping);
return newAsset.Hierarchy;
}
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:27,代码来源:EntityGroupAssetOperations.cs
示例5: Load
public object Load(Stream stream, UFile filePath, ILogger log, out bool aliasOccurred, out Dictionary<YamlAssetPath, OverrideType> overrides)
{
PropertyContainer properties;
var result = AssetYamlSerializer.Default.Deserialize(stream, null, log != null ? new SerializerContextSettings { Logger = log } : null, out aliasOccurred, out properties);
properties.TryGetValue(AssetObjectSerializerBackend.OverrideDictionaryKey, out overrides);
return result;
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:7,代码来源:YamlAssetSerializer.cs
示例6: Load
public object Load(Stream stream, UFile filePath, ILogger log, out bool aliasOccurred, out Dictionary<YamlAssetPath, OverrideType> overrides)
{
aliasOccurred = false;
var assetFileExtension = filePath.GetFileExtension().ToLowerInvariant();
var type = AssetRegistry.GetAssetTypeFromFileExtension(assetFileExtension);
var asset = (SourceCodeAsset)Activator.CreateInstance(type);
var textAccessor = asset.TextAccessor as SourceCodeAsset.DefaultTextAccessor;
if (textAccessor != null)
{
// Don't load the file if we have the file path
textAccessor.FilePath = filePath;
// Set the assets text if it loaded from an in-memory version
// TODO: Propagate dirtiness?
if (stream is MemoryStream)
{
var reader = new StreamReader(stream, Encoding.UTF8);
textAccessor.Set(reader.ReadToEnd());
}
}
// No override in source code assets
overrides = new Dictionary<YamlAssetPath, OverrideType>();
return asset;
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:28,代码来源:SourceCodeAssetSerializer.cs
示例7: IsSupportingFile
public static bool IsSupportingFile(this IAssetImporter importer, UFile file)
{
if (file == null) throw new ArgumentNullException("file");
if (file.GetFileExtension() == null) return false;
return FileUtility.GetFileExtensionsAsSet(importer.SupportedFileExtensions).Contains(file.GetFileExtension());
}
开发者ID:Powerino73,项目名称:paradox,代码行数:7,代码来源:IAssetImporter.cs
示例8: DoCommandOverride
protected override Task<ResultStatus> DoCommandOverride(ICommandContext commandContext)
{
// This path for effects xml is now part of this tool, but it should be done in a separate exporter?
using (var inputStream = File.OpenRead(SourcePath))
using (var outputStream = AssetManager.FileProvider.OpenStream(Location, VirtualFileMode.Create, VirtualFileAccess.Write))
{
inputStream.CopyTo(outputStream);
var objectURL = new ObjectUrl(UrlType.ContentLink, Location);
if (DisableCompression)
commandContext.AddTag(objectURL, DisableCompressionSymbol);
}
if (SaveSourcePath)
{
// store absolute path to source
// TODO: the "/path" is hardcoded, used in EffectSystem and ShaderSourceManager. Find a place to share this correctly.
var pathLocation = new UFile(Location.FullPath + "/path");
using (var outputStreamPath = AssetManager.FileProvider.OpenStream(pathLocation, VirtualFileMode.Create, VirtualFileAccess.Write))
{
using (var sw = new StreamWriter(outputStreamPath))
{
sw.Write(SourcePath.FullPath);
}
}
}
return Task.FromResult(ResultStatus.Successful);
}
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:30,代码来源:ImportStreamCommand.cs
示例9: SettingsEntry
/// <summary>
/// Initializes a new instance of the <see cref="SettingsEntry"/> class.
/// </summary>
/// <param name="profile">The profile this <see cref="SettingsEntry"/>belongs to.</param>
/// <param name="name">The name associated to this <see cref="SettingsEntry"/>.</param>
protected SettingsEntry(SettingsProfile profile, UFile name)
{
if (profile == null) throw new ArgumentNullException("profile");
if (name == null) throw new ArgumentNullException("name");
Profile = profile;
Name = name;
}
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:12,代码来源:SettingsEntry.cs
示例10: IsSupportingFile
public virtual bool IsSupportingFile(string filePath)
{
if (filePath == null) throw new ArgumentNullException("filePath");
var file = new UFile(filePath);
if (file.GetFileExtension() == null) return false;
return FileUtility.GetFileExtensionsAsSet(SupportedFileExtensions).Contains(file.GetFileExtension());
}
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:8,代码来源:AssetImporterBase.cs
示例11: SettingsKey
/// <summary>
/// Initializes a new instance of the <see cref="SettingsKey"/> class.
/// </summary>
/// <param name="name">The name of this settings key. Must be unique amongst the application.</param>
/// <param name="container">The <see cref="SettingsContainer"/> containing this <see cref="SettingsKey"/>.</param>
/// <param name="defaultValue">The default value associated to this settings key.</param>
protected SettingsKey(UFile name, SettingsContainer container, object defaultValue)
{
Name = name;
DisplayName = name;
DefaultObjectValue = defaultValue;
Container = container;
Container.RegisterSettingsKey(name, defaultValue, this);
}
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:14,代码来源:SettingsKey.cs
示例12: PackageLoadingAssetFile
/// <summary>
/// Initializes a new instance of the <see cref="PackageLoadingAssetFile" /> class.
/// </summary>
/// <param name="package">The package this asset will be part of.</param>
/// <param name="filePath">The relative file path (from default asset folder).</param>
/// <param name="sourceFolder">The source folder (optional, can be null).</param>
/// <exception cref="System.ArgumentException">filePath must be relative</exception>
public PackageLoadingAssetFile(Package package, UFile filePath, UDirectory sourceFolder)
{
if (filePath.IsAbsolute)
throw new ArgumentException("filePath must be relative", filePath);
SourceFolder = UPath.Combine(package.RootDirectory, sourceFolder ?? package.GetDefaultAssetFolder());
FilePath = UPath.Combine(SourceFolder, filePath);
}
开发者ID:robterrell,项目名称:paradox,代码行数:15,代码来源:PackageLoadingAssetFile.cs
示例13: SettingsKey
/// <summary>
/// Initializes a new instance of the <see cref="SettingsKey"/> class.
/// </summary>
/// <param name="name">The name of this settings key. Must be unique amongst the application.</param>
/// <param name="group">The <see cref="SettingsGroup"/> containing this <see cref="SettingsKey"/>.</param>
/// <param name="defaultValueCallback">A function that returns the default value associated to this settings key.</param>
protected SettingsKey(UFile name, SettingsGroup group, Func<object> defaultValueCallback)
{
Name = name;
DisplayName = name;
DefaultObjectValueCallback = defaultValueCallback;
Group = group;
Group.RegisterSettingsKey(name, defaultValueCallback(), this);
}
开发者ID:robterrell,项目名称:paradox,代码行数:14,代码来源:SettingsKey.cs
示例14: Import
/// <summary>
/// Imports the model.
/// </summary>
/// <param name="localPath">The path of the asset.</param>
/// <param name="importParameters">The parameters used to import the model.</param>
/// <returns>A collection of assets.</returns>
public override IEnumerable<AssetItem> Import(UFile localPath, AssetImporterParameters importParameters)
{
var rawAssetReferences = new List<AssetItem>(); // the asset references without subdirectory path
var entityInfo = GetEntityInfo(localPath, importParameters.Logger);
//var isImportingEntity = importParameters.IsTypeSelectedForOutput<EntityAsset>();
var isImportingModel = importParameters.IsTypeSelectedForOutput<ModelAsset>();
var isImportingMaterial = importParameters.IsTypeSelectedForOutput<MaterialAsset>() ||
isImportingModel;
var isImportingTexture = importParameters.IsTypeSelectedForOutput<TextureAsset>() ||
isImportingMaterial;
// 1. Textures
if (isImportingTexture)
{
ImportTextures(entityInfo.TextureDependencies, rawAssetReferences);
}
// 2. Skeleton
AssetItem skeletonAsset = null;
if (importParameters.IsTypeSelectedForOutput<SkeletonAsset>())
{
skeletonAsset = ImportSkeleton(rawAssetReferences, localPath, localPath, entityInfo);
}
// 3. Animation
if (importParameters.IsTypeSelectedForOutput<AnimationAsset>())
{
ImportAnimation(rawAssetReferences, localPath, entityInfo.AnimationNodes, isImportingModel, skeletonAsset);
}
// 4. Materials
if (isImportingMaterial)
{
ImportMaterials(rawAssetReferences, entityInfo.Materials);
}
// 5. Model
if (isImportingModel)
{
var modelItem = ImportModel(rawAssetReferences, localPath, localPath, entityInfo, false, skeletonAsset);
// 5. Entity (currently disabled)
//if (isImportingEntity)
//{
// var entityAssetItem = ImportEntity(rawAssetReferences, localPath, modelItem);
//
// // Apply EntityAnalysis
// EntityAnalysis.UpdateEntityReferences(((EntityAsset)entityAssetItem.Asset).Hierarchy);
//}
}
return rawAssetReferences;
}
开发者ID:joewan,项目名称:xenko,代码行数:64,代码来源:ModelAssetImporter.cs
示例15: Import
public override IEnumerable<AssetItem> Import(UFile rawAssetPath, AssetImporterParameters importParameters)
{
var asset = new TextureAsset { Source = rawAssetPath };
// Creates the url to the texture
var textureUrl = new UFile(rawAssetPath.GetFileName(), null);
yield return new AssetItem(textureUrl, asset);
}
开发者ID:releed,项目名称:paradox,代码行数:9,代码来源:TextureImporter.cs
示例16: RegisterLocation
/// <summary>
/// Finds a name available for a new asset. This method will try to create a name based on an existing name and will append
/// "_" + (number++) on every try. The new location found is added to the known existing locations.
/// </summary>
/// <param name="location">The location.</param>
/// <param name="newLocation">The new location.</param>
/// <returns><c>true</c> if there is a new location, <c>false</c> otherwise.</returns>
public bool RegisterLocation(UFile location, out UFile newLocation)
{
newLocation = location;
if (IsContainingLocation(location))
{
newLocation = NamingHelper.ComputeNewName(location, IsContainingLocation);
}
ExistingLocations.Add(newLocation);
return newLocation != location;
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:17,代码来源:AssetResolver.cs
示例17: DoCommandOverride
/// <inheritdoc/>
protected override Task<ResultStatus> DoCommandOverride(ICommandContext commandContext)
{
var gameSettings = context.GetGameSettingsAsset();
// Find default scene URL
var defaultSceneUrl = gameSettings.DefaultScene != null ? AttachedReferenceManager.GetUrl(gameSettings.DefaultScene) : null;
if (defaultSceneUrl == null)
return Task.FromResult(ResultStatus.Successful);
var baseUrl = new UFile(defaultSceneUrl).GetParent();
try
{
commandContext.Logger.Info($"Trying to compile effects for scene '{defaultSceneUrl}'");
using (var sceneRenderer = new SceneRenderer(gameSettings))
{
// Effect can be compiled asynchronously (since we don't have any fallback, they will have to be compiled in the same frame anyway)
// Also set the file provider to the current transaction
((EffectCompilerCache)sceneRenderer.EffectSystem.Compiler).CompileEffectAsynchronously = true;
((EffectCompilerCache)sceneRenderer.EffectSystem.Compiler).FileProvider = MicrothreadLocalDatabases.DatabaseFileProvider;
((EffectCompilerCache)sceneRenderer.EffectSystem.Compiler).CurrentCache = EffectBytecodeCacheLoadSource.StartupCache;
sceneRenderer.EffectSystem.EffectUsed += (effectCompileRequest, result) => compilerResult.BuildSteps.Add(EffectCompileCommand.FromRequest(context, package, baseUrl, effectCompileRequest));
sceneRenderer.GameSystems.LoadContent();
// Load the scene
var scene = sceneRenderer.ContentManager.Load<Scene>(defaultSceneUrl);
sceneRenderer.SceneSystem.SceneInstance = new SceneInstance(sceneRenderer.Services, scene, ExecutionMode.EffectCompile);
// Disable culling
sceneRenderer.SceneSystem.SceneInstance.VisibilityGroups.CollectionChanged += (sender, e) =>
{
if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
{
((VisibilityGroup)e.Item).DisableCulling = true;
}
};
// Update and draw
// This will force effects to be generated and saved in the object database
var time = new GameTime();
sceneRenderer.GameSystems.Update(time);
sceneRenderer.GraphicsContext.ResourceGroupAllocator.Reset(sceneRenderer.GraphicsContext.CommandList);
sceneRenderer.GameSystems.Draw(time);
}
}
catch (Exception e)
{
commandContext.Logger.Warning($"Could not compile effects for scene '{defaultSceneUrl}': {e.Message + e.StackTrace}", e);
}
return Task.FromResult(ResultStatus.Successful);
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:55,代码来源:CompileDefaultSceneEffectCommand.cs
示例18: ChangeFileExtension
private void ChangeFileExtension(IList<PackageLoadingAssetFile> assetFiles, PackageLoadingAssetFile file, string newExtension)
{
// Create the new file
var newFileName = new UFile(file.FilePath.FullPath.Replace(file.FilePath.GetFileExtension(), ".pdxsheet"));
var newFile = new PackageLoadingAssetFile(newFileName, file.SourceFolder) { AssetContent = file.AssetContent };
// Add the new file
assetFiles.Add(newFile);
// Mark the old file as "To Delete"
file.Deleted = true;
}
开发者ID:hck509,项目名称:paradox,代码行数:12,代码来源:ParadoxPackageUpgrader.cs
示例19: Import
public override IEnumerable<AssetItem> Import(UFile rawAssetPath, AssetImporterParameters importParameters)
{
var outputAssets = new List<AssetItem>();
if (!SpriteStudioXmlImport.SanityCheck(rawAssetPath))
{
importParameters.Logger.Error("Invalid xml file or some required files are missing.");
return null;
}
//pre-process models
var nodes = new List<SpriteStudioNode>();
string modelName;
if (!SpriteStudioXmlImport.ParseModel(rawAssetPath, nodes, out modelName))
{
importParameters.Logger.Error("Failed to parse Sprite Studio model.");
return null;
}
if (importParameters.IsTypeSelectedForOutput<SpriteStudioModelAsset>())
{
var model = new SpriteStudioModelAsset { Source = rawAssetPath };
foreach (var node in nodes)
{
model.NodeNames.Add(node.Name);
}
outputAssets.Add(new AssetItem(modelName, model));
}
if (importParameters.IsTypeSelectedForOutput<SpriteStudioAnimationAsset>())
{
//pre-process anims
var anims = new List<SpriteStudioAnim>();
if (!SpriteStudioXmlImport.ParseAnimations(rawAssetPath, anims))
{
importParameters.Logger.Error("Failed to parse Sprite Studio animations.");
return null;
}
foreach (var studioAnim in anims)
{
var anim = new SpriteStudioAnimationAsset { Source = rawAssetPath, AnimationName = studioAnim.Name };
outputAssets.Add(new AssetItem(modelName + "_" + studioAnim.Name, anim));
}
}
return outputAssets;
}
开发者ID:RainsSoft,项目名称:paradox,代码行数:48,代码来源:SpriteStudioImporter.cs
示例20: Import
/// <summary>
/// Imports the model.
/// </summary>
/// <param name="localPath">The path of the asset.</param>
/// <param name="importParameters">The parameters used to import the model.</param>
/// <returns>A collection of assets.</returns>
public override IEnumerable<AssetItem> Import(UFile localPath, AssetImporterParameters importParameters)
{
var rawAssetReferences = new List<AssetItem>(); // the asset references without subdirectory path
var entityInfo = GetEntityInfo(localPath, importParameters.Logger, importParameters);
//var isImportingEntity = importParameters.IsTypeSelectedForOutput<PrefabAsset>();
var isImportingModel = importParameters.IsTypeSelectedForOutput<ModelAsset>();
var isImportingMaterial = importParameters.IsTypeSelectedForOutput<MaterialAsset>();
var isImportingTexture = importParameters.IsTypeSelectedForOutput<TextureAsset>();
// 1. Textures
if (isImportingTexture)
{
ImportTextures(entityInfo.TextureDependencies, rawAssetReferences);
}
// 2. Skeleton
AssetItem skeletonAsset = null;
if (importParameters.IsTypeSelectedForOutput<SkeletonAsset>())
{
skeletonAsset = ImportSkeleton(rawAssetReferences, localPath, localPath, entityInfo);
}
// 3. Animation
if (importParameters.IsTypeSelectedForOutput<AnimationAsset>())
{
ImportAnimation(rawAssetReferences, localPath, entityInfo.AnimationNodes, isImportingModel, skeletonAsset);
}
// 4. Materials
if (isImportingMaterial)
{
ImportMaterials(rawAssetReferences, entityInfo.Materials);
}
// 5. Model
if (isImportingModel)
{
ImportModel(rawAssetReferences, localPath, localPath, entityInfo, false, skeletonAsset);
}
return rawAssetReferences;
}
开发者ID:cg123,项目名称:xenko,代码行数:53,代码来源:ModelAssetImporter.cs
注:本文中的SiliconStudio.Core.IO.UFile类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论