本文整理汇总了C#中SiliconStudio.Core.IO.UFile.GetFileName方法的典型用法代码示例。如果您正苦于以下问题:C# UFile.GetFileName方法的具体用法?C# UFile.GetFileName怎么用?C# UFile.GetFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SiliconStudio.Core.IO.UFile
的用法示例。
在下文中一共展示了UFile.GetFileName方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: ImportTextures
private static void ImportTextures(IEnumerable<string> textureDependencies, List<AssetItem> assetReferences)
{
if (textureDependencies == null)
return;
foreach (var textureFullPath in textureDependencies.Distinct(x => x))
{
var texturePath = new UFile(textureFullPath);
var source = texturePath;
var texture = new TextureAsset { Source = source, PremultiplyAlpha = false };
// Create asset reference
assetReferences.Add(new AssetItem(texturePath.GetFileName(), texture));
}
}
示例3: Import
public override IEnumerable<AssetItem> Import(UFile rawAssetPath, AssetImporterParameters importParameters)
{
// Creates the url to the texture
var asset = new AssetImportObjectTest
{
Source = rawAssetPath,
Name = rawAssetPath.GetFileName() + "Name"
};
var assetUrl = new UFile(rawAssetPath.GetFileName(), null);
// Emulate a change in a sub-asset
var subAsset = new AssetObjectTestSub() { Value = value };
value++;
var subAssetItem = new AssetItem(rawAssetPath.GetFileName() + "_SubAsset", subAsset);
asset.References.Add("Test", new AssetReference<AssetObjectTestSub>(subAsset.Id, subAssetItem.Location));
var list = new List<AssetItem>
{
new AssetItem(assetUrl, asset),
subAssetItem
};
return list;
}
示例4: ImportAnimation
private static void ImportAnimation(List<AssetItem> assetReferences, UFile localPath, List<string> animationNodes, bool shouldPostFixName)
{
if (animationNodes != null && animationNodes.Count > 0)
{
var assetSource = localPath;
var asset = new AnimationAsset { Source = assetSource };
var animUrl = localPath.GetFileName() + (shouldPostFixName? " Animation": "");
assetReferences.Add(new AssetItem(animUrl, asset));
}
}
示例5: ImportModel
private static AssetItem ImportModel(List<AssetItem> assetReferences, UFile assetSource, UFile localPath, EntityInfo entityInfo, bool shouldPostFixName)
{
var asset = new ModelAsset { Source = assetSource };
if (entityInfo.Models != null)
{
var loadedMaterials = assetReferences.Where(x => x.Asset is MaterialAsset).ToList();
foreach (var material in entityInfo.Materials)
{
var foundMaterial = loadedMaterials.FirstOrDefault(x => x.Location == new UFile(material.Key, null));
if (foundMaterial != null)
asset.Materials.Add(new ModelMaterial { Name = material.Key, MaterialInstance = new MaterialInstance() { Material = AttachedReferenceManager.CreateSerializableVersion<Material>(foundMaterial.Id, foundMaterial.Location) } });
}
}
if (entityInfo.Nodes != null)
{
foreach (var node in entityInfo.Nodes)
asset.Nodes.Add(new NodeInformation(node.Name, node.Depth, node.Preserve));
}
if (entityInfo.AnimationNodes != null && entityInfo.AnimationNodes.Count > 0)
asset.PreserveNodes(entityInfo.AnimationNodes);
var modelUrl = new UFile(localPath.GetFileName() + (shouldPostFixName?" Model": ""), null);
var assetItem = new AssetItem(modelUrl, asset);
assetReferences.Add(assetItem);
return assetItem;
}
示例6: ImportAnimation
private static void ImportAnimation(List<AssetItem> assetReferences, UFile localPath, List<string> animationNodes, bool shouldPostFixName, AssetItem skeletonAsset)
{
if (animationNodes != null && animationNodes.Count > 0)
{
var assetSource = localPath;
var asset = new AnimationAsset { Source = assetSource };
var animUrl = localPath.GetFileName() + (shouldPostFixName ? " Animation" : "");
if (skeletonAsset != null)
asset.Skeleton = AttachedReferenceManager.CreateProxyObject<Skeleton>(skeletonAsset.Id, skeletonAsset.Location);
assetReferences.Add(new AssetItem(animUrl, asset));
}
}
示例7: ImportModel
private static AssetItem ImportModel(List<AssetItem> assetReferences, UFile assetSource, UFile localPath, EntityInfo entityInfo, bool shouldPostFixName, AssetItem skeletonAsset)
{
var asset = new ModelAsset { Source = assetSource };
if (entityInfo.Models != null)
{
var loadedMaterials = assetReferences.Where(x => x.Asset is MaterialAsset).ToList();
foreach (var material in entityInfo.Materials)
{
var modelMaterial = new ModelMaterial
{
Name = material.Key,
MaterialInstance = new MaterialInstance()
};
var foundMaterial = loadedMaterials.FirstOrDefault(x => x.Location == new UFile(material.Key));
if (foundMaterial != null)
{
var reference = AttachedReferenceManager.CreateProxyObject<Material>(foundMaterial.Id, foundMaterial.Location);
modelMaterial.MaterialInstance.Material = reference;
}
//todo Instead of null material add a default xenko material
asset.Materials.Add(AttachId(modelMaterial));
}
//handle the case where during import we imported no materials at all
//todo Instead of null material add a default xenko material
if (entityInfo.Materials.Count == 0)
{
var modelMaterial = new ModelMaterial { Name = "Material", MaterialInstance = new MaterialInstance() };
asset.Materials.Add(AttachId(modelMaterial));
}
}
if (skeletonAsset != null)
asset.Skeleton = AttachedReferenceManager.CreateProxyObject<Skeleton>(skeletonAsset.Id, skeletonAsset.Location);
var modelUrl = new UFile(localPath.GetFileName() + (shouldPostFixName?" Model": ""));
var assetItem = new AssetItem(modelUrl, asset);
assetReferences.Add(assetItem);
return assetItem;
}
示例8: ImportSkeleton
private static AssetItem ImportSkeleton(List<AssetItem> assetReferences, UFile assetSource, UFile localPath, EntityInfo entityInfo)
{
var asset = new SkeletonAsset { Source = assetSource };
if (entityInfo.Nodes != null)
{
foreach (var node in entityInfo.Nodes)
asset.Nodes.Add(new NodeInformation(node.Name, node.Depth, node.Preserve));
}
if (entityInfo.AnimationNodes != null && entityInfo.AnimationNodes.Count > 0)
asset.PreserveNodes(entityInfo.AnimationNodes);
var skeletonUrl = new UFile(localPath.GetFileName() + " Skeleton", null);
var assetItem = new AssetItem(skeletonUrl, asset);
assetReferences.Add(assetItem);
return assetItem;
}
示例9: ImportSkeleton
private static AssetItem ImportSkeleton(List<AssetItem> assetReferences, UFile assetSource, UFile localPath, EntityInfo entityInfo)
{
var asset = new SkeletonAsset { Source = assetSource };
if (entityInfo.Nodes != null)
{
for (int i = 0; i < entityInfo.Nodes.Count; i++)
{
var node = entityInfo.Nodes[i];
var nodeInfo = new NodeInformation(node.Name, node.Depth, node.Preserve);
// Try to keep identifier id consistent
// TODO: We might remove this as we don't expect Skeleton asset to be inherited, but they could
int sameNameAndDepthCount = 0;
for (int j = 0; j < i; j++)
{
var againstNode = entityInfo.Nodes[i];
// If we found a node with the same name and depth, we use a increment a counter
if (againstNode.Name == node.Name && againstNode.Depth == node.Depth)
{
sameNameAndDepthCount++;
}
}
var nodeNameKey = nodeInfo.Name + nodeInfo.Depth + ((sameNameAndDepthCount > 0) ? "_" + sameNameAndDepthCount : string.Empty);
var nodeId = ObjectId.FromBytes(Encoding.UTF8.GetBytes(nodeNameKey)).ToGuid();
IdentifiableHelper.SetId(nodeInfo, nodeId);
asset.Nodes.Add(nodeInfo);
}
}
if (entityInfo.AnimationNodes != null && entityInfo.AnimationNodes.Count > 0)
asset.PreserveNodes(entityInfo.AnimationNodes);
var skeletonUrl = new UFile(localPath.GetFileName() + " Skeleton");
var assetItem = new AssetItem(skeletonUrl, asset);
assetReferences.Add(assetItem);
return assetItem;
}
示例10: GenerateSeparateTextureURL
private static string GenerateSeparateTextureURL(UFile originalLocation, string suffixName)
{
return originalLocation.GetDirectory() + "/" + SplittedTextureNamePrefix + originalLocation.GetFileName() + suffixName;
}
示例11: ImportEntity
private static AssetItem ImportEntity(List<AssetItem> assetReferences, UFile localPath, AssetItem modelItem)
{
var entityUrl = new UFile(localPath.GetFileName(), null);
// TODO: Entities do not have source anymore, if this is needed again we should make scene assets that do not inherits from entity assets.
var asset = new EntityAsset(); // { Source = localPath };
var rootEntityData = new Entity();
asset.Hierarchy.Entities.Add(rootEntityData);
asset.Hierarchy.RootEntity = rootEntityData.Id;
rootEntityData.Name = entityUrl;
// Use modelUrl.Path to get the url without the extension
rootEntityData.Add(ModelComponent.Key, new ModelComponent { Model = AttachedReferenceManager.CreateSerializableVersion<Rendering.Model>(modelItem.Id, modelItem.Location) });
var assetReference = new AssetItem(entityUrl, asset);
assetReferences.Add(assetReference);
return assetReference;
}
示例12: ImportEntity
private static AssetItem ImportEntity(List<AssetItem> assetReferences, UFile localPath, AssetItem modelItem)
{
var entityUrl = new UFile(localPath.GetFileName(), null);
var asset = new EntityAsset { Source = localPath };
var rootEntityData = new Entity();
asset.Hierarchy.Entities.Add(rootEntityData);
asset.Hierarchy.RootEntity = rootEntityData.Id;
rootEntityData.Name = entityUrl;
// Use modelUrl.Path to get the url without the extension
rootEntityData.Add(ModelComponent.Key, new ModelComponent { Model = AttachedReferenceManager.CreateSerializableVersion<Rendering.Model>(modelItem.Id, modelItem.Location) });
var assetReference = new AssetItem(entityUrl, asset);
assetReferences.Add(assetReference);
return assetReference;
}
示例13: TestWithNormalization
public void TestWithNormalization()
{
var assetPath = new UFile("/a/b/.././././//c.txt");
Assert.AreEqual("/a", assetPath.GetDirectory());
Assert.AreEqual("c", assetPath.GetFileName());
Assert.AreEqual(".txt", assetPath.GetFileExtension());
Assert.AreEqual("/a/c", assetPath.GetDirectoryAndFileName());
Assert.AreEqual("/a/c.txt", assetPath.FullPath);
assetPath = new UFile("../.././././//c.txt");
Assert.AreEqual("../..", assetPath.GetDirectory());
Assert.AreEqual("c", assetPath.GetFileName());
Assert.AreEqual(".txt", assetPath.GetFileExtension());
Assert.AreEqual("../../c", assetPath.GetDirectoryAndFileName());
Assert.AreEqual("../../c.txt", assetPath.FullPath);
assetPath = new UFile("a/../../../c.txt");
Assert.AreEqual("../../c.txt", assetPath.FullPath);
}
示例14: TestWithSimplePathWithExtension
public void TestWithSimplePathWithExtension()
{
var assetPath = new UFile("/a/b/c.txt");
Assert.AreEqual("/a/b", assetPath.GetDirectory());
Assert.AreEqual("c", assetPath.GetFileName());
Assert.AreEqual(".txt", assetPath.GetFileExtension());
Assert.AreEqual("/a/b/c", assetPath.GetDirectoryAndFileName());
Assert.AreEqual("/a/b/c.txt", assetPath.FullPath);
}