本文整理汇总了C#中AssetItem类的典型用法代码示例。如果您正苦于以下问题:C# AssetItem类的具体用法?C# AssetItem怎么用?C# AssetItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AssetItem类属于命名空间,在下文中一共展示了AssetItem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: AssetToImportMerge
/// <summary>
/// Initializes a new instance of the <see cref="AssetToImportMerge"/> class.
/// </summary>
/// <param name="previousItem">The previous item.</param>
/// <param name="diff">The difference.</param>
/// <param name="mergePreviewResult">The merge preview result.</param>
internal AssetToImportMerge(AssetItem previousItem, AssetDiff diff, MergeResult mergePreviewResult)
{
PreviousItem = previousItem;
this.Diff = diff;
this.MergePreviewResult = mergePreviewResult;
DependencyGroups = new List<AssetToImportMergeGroup>();
}
开发者ID:Powerino73,项目名称:paradox,代码行数:13,代码来源:AssetToImportMerge.cs
示例2: Compile
protected override void Compile(AssetCompilerContext context, AssetItem assetItem, string targetUrlInStorage, AssetCompilerResult result)
{
var asset = (EffectLogAsset)assetItem.Asset;
var originalSourcePath = assetItem.FullPath;
result.ShouldWaitForPreviousBuilds = true;
result.BuildSteps = new AssetBuildStep(assetItem) { new EffectLogBuildStep(context, originalSourcePath, assetItem) };
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:7,代码来源:EffectLogAssetCompiler.cs
示例3: AssetCompiledArgs
/// <summary>
/// Constructs an <see cref="AssetCompiledArgs"/> instance.
/// </summary>
/// <param name="asset">The asset that has been compiled. Cannot be null.</param>
/// <param name="result">The result of the asset compilation. Cannot be null.</param>
public AssetCompiledArgs(AssetItem asset, AssetCompilerResult result)
{
if (asset == null) throw new ArgumentNullException("asset");
if (result == null) throw new ArgumentNullException("result");
Asset = asset;
Result = result;
}
开发者ID:cg123,项目名称:xenko,代码行数:12,代码来源:AssetCompiledArgs.cs
示例4: AssetItemMutable
public AssetItemMutable(AssetItem item)
{
Location = item.Location;
SourceFolder = item.SourceFolder;
Asset = item.Asset;
ProjectFile = item.SourceProject;
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:7,代码来源:AssetItemSerializer.cs
示例5: SaveGeneratedAsset
public override void SaveGeneratedAsset(AssetItem assetItem)
{
//generate the .cs files
// Always output a result into the file
string result;
try
{
var parsingResult = XenkoShaderParser.TryPreProcessAndParse(Text, assetItem.FullPath);
if (parsingResult.HasErrors)
{
result = "// Failed to parse the shader:\n" + parsingResult;
}
else
{
// Try to generate a mixin code.
var shaderKeyGenerator = new ShaderMixinCodeGen(parsingResult.Shader, parsingResult);
shaderKeyGenerator.Run();
result = shaderKeyGenerator.Text ?? string.Empty;
}
}
catch (Exception ex)
{
result = "// Unexpected exceptions occurred while generating the file\n" + ex;
}
// We force the UTF8 to include the BOM to match VS default
var data = Encoding.UTF8.GetBytes(result);
File.WriteAllBytes(assetItem.GetGeneratedAbsolutePath(), data);
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:32,代码来源:EffectShaderAsset.cs
示例6: 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
示例7: Compile
/// <inheritdoc/>
public AssetCompilerResult Compile(CompilerContext context, AssetItem assetItem)
{
if (context == null) throw new ArgumentNullException("context");
if (assetItem == null) throw new ArgumentNullException("assetItem");
var compilerResult = new AssetCompilerResult();
if (assetItem.Package == null)
{
compilerResult.Warning("Asset [{0}] is not attached to a package", assetItem);
return compilerResult;
}
var assetCompilerContext = (AssetCompilerContext)context;
// create the a package that contains only the asset and its the dependencies
var dependenciesCompilePackage = assetItem.Package.Session.CreateCompilePackageFromAsset(assetItem);
var clonedAsset = dependenciesCompilePackage.FindAsset(assetItem.Id);
CompileWithDependencies(assetCompilerContext, clonedAsset, assetItem, compilerResult);
// Check unloadable items
foreach (var currentAssetItem in dependenciesCompilePackage.Assets)
{
var unloadableItems = UnloadableObjectRemover.Run(currentAssetItem.Asset);
foreach (var unloadableItem in unloadableItems)
{
compilerResult.Log(new AssetLogMessage(dependenciesCompilePackage, currentAssetItem.ToReference(), LogMessageType.Warning, $"Unable to load the object of type {unloadableItem.UnloadableObject.TypeName} which is located at [{unloadableItem.MemberPath}] in the asset"));
}
}
// Find AssetBuildStep
var assetBuildSteps = new Dictionary<AssetId, AssetBuildStep>();
foreach (var step in compilerResult.BuildSteps.EnumerateRecursively())
{
var assetStep = step as AssetBuildStep;
if (assetStep != null)
{
assetBuildSteps[assetStep.AssetItem.Id] = assetStep;
}
}
// TODO: Refactor logging of CompilerApp and BuildEngine
// Copy log top-level to proper asset build steps
foreach (var message in compilerResult.Messages)
{
var assetMessage = message as AssetLogMessage;
// Find asset (if nothing found, default to main asset)
var assetId = assetMessage?.AssetReference.Id ?? assetItem.Id;
AssetBuildStep assetBuildStep;
if (assetBuildSteps.TryGetValue(assetId, out assetBuildStep))
{
// Log to AssetBuildStep
assetBuildStep.Logger?.Log(message);
}
}
return compilerResult;
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:61,代码来源:AssetDependenciesCompiler.cs
示例8: Compile
/// <inheritdoc/>
public AssetCompilerResult Compile(CompilerContext context, AssetItem assetItem)
{
if (context == null) throw new ArgumentNullException("context");
if (assetItem == null) throw new ArgumentNullException("assetItem");
assetItem = assetItem.Package.Session.DependencyManager.FindDependencySet(assetItem.Id).Item;
var compilerResult = new AssetCompilerResult();
if (assetItem.Package == null)
{
compilerResult.Warning("Asset [{0}] is not attached to a package", assetItem);
return compilerResult;
}
var assetCompilerContext = (AssetCompilerContext)context;
// create the a package that contains only the asset and its the dependencies
var dependenciesCompilePackage = assetItem.Package.Session.CreateCompilePackageFromAsset(assetItem);
assetCompilerContext.Package = dependenciesCompilePackage.LocalPackages.FirstOrDefault();
var clonedAsset = dependenciesCompilePackage.FindAsset(assetItem.Id);
CompileWithDependencies(assetCompilerContext, clonedAsset, assetItem, compilerResult);
return compilerResult;
}
开发者ID:Julyuary,项目名称:paradox,代码行数:27,代码来源:AssetDependenciesCompiler.cs
示例9: Compile
protected override void Compile(AssetCompilerContext context, AssetItem assetItem, string targetUrlInStorage, AssetCompilerResult result)
{
var asset = (SkeletonAsset)assetItem.Asset;
var assetSource = GetAbsolutePath(assetItem, asset.Source);
var extension = assetSource.GetFileExtension();
var buildStep = new AssetBuildStep(assetItem);
var importModelCommand = ImportModelCommand.Create(extension);
if (importModelCommand == null)
{
result.Error("No importer found for model extension '{0}. The model '{1}' can't be imported.", extension, assetSource);
return;
}
importModelCommand.SourcePath = assetSource;
importModelCommand.Location = targetUrlInStorage;
importModelCommand.Mode = ImportModelCommand.ExportMode.Skeleton;
importModelCommand.ScaleImport = asset.ScaleImport;
importModelCommand.PivotPosition = asset.PivotPosition;
importModelCommand.SkeletonNodesWithPreserveInfo = asset.NodesWithPreserveInfo;
buildStep.Add(importModelCommand);
result.BuildSteps = buildStep;
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:25,代码来源:SkeletonAssetCompiler.cs
示例10: LoadAssets
static void LoadAssets()
{
// Get all assets that contained in different Resources folders
var rootPaths = AssetDatabase.FindAssets("Resources").Select(item => AssetDatabase.GUIDToAssetPath(item));
_assets = new List<AssetItem>();
foreach(var path in rootPaths)
{
var dirInfo = new DirectoryInfo(path);
// Exclude temporary folder if it contains "Resources" word
if (!string.Equals(dirInfo.Name, _tempFolderName))
{
var rootItem = new AssetItem();
rootItem.path = path;
rootItem.name = dirInfo.Name;
rootItem.isFolder = true;
rootItem.AddChild(GetSubAssets(rootItem.path));
_assets.Add(rootItem);
}
}
if (File.Exists(GetAbsolutePath(_saveDataPath)))
{
if (!cleared)
{
LoadData();
}
}
init = true;
}
开发者ID:t1mmmmY,项目名称:ResourceManager,代码行数:33,代码来源:ResourceManager.cs
示例11: EnsureSourcesExist
/// <summary>
/// Ensures that the sources of an <see cref="Asset"/> exist.
/// </summary>
/// <param name="result">The <see cref="AssetCompilerResult"/> in which to output log of potential errors.</param>
/// <param name="assetItem">The asset to check.</param>
/// <returns><c>true</c> if the source file exists, <c>false</c> otherwise.</returns>
/// <exception cref="ArgumentNullException">Any of the argument is <c>null</c>.</exception>
private static bool EnsureSourcesExist(AssetCompilerResult result, AssetItem assetItem)
{
if (result == null) throw new ArgumentNullException(nameof(result));
if (assetItem == null) throw new ArgumentNullException(nameof(assetItem));
var collector = new SourceFilesCollector();
var sourceMembers = collector.GetSourceMembers(assetItem.Asset);
foreach (var member in sourceMembers)
{
if (string.IsNullOrEmpty(member.Value))
{
result.Error($"Source is null for Asset [{assetItem}] in property [{member.Key}]");
return false;
}
// Get absolute path of asset source on disk
var assetDirectory = assetItem.FullPath.GetParent();
var assetSource = UPath.Combine(assetDirectory, member.Value);
// Ensure the file exists
if (!File.Exists(assetSource))
{
result.Error($"Unable to find the source file '{assetSource}' for Asset [{assetItem}]");
return false;
}
}
return true;
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:37,代码来源:AssetCompilerBase.cs
示例12: 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
示例13: Compile
public AssetCompilerResult Compile(CompilerContext context, AssetItem assetItem)
{
if (context == null) throw new ArgumentNullException(nameof(context));
if (assetItem == null) throw new ArgumentNullException(nameof(assetItem));
var result = new AssetCompilerResult(GetType().Name)
{
BuildSteps = new AssetBuildStep(assetItem)
};
// Only use the path to the asset without its extension
var fullPath = assetItem.FullPath;
if (!fullPath.IsAbsolute)
{
throw new InvalidOperationException("assetItem must be an absolute path");
}
// Try to compile only if we're sure that the sources exist.
if (EnsureSourcesExist(result, assetItem))
{
Compile((AssetCompilerContext)context, assetItem, assetItem.Location.GetDirectoryAndFileName(), result);
}
return result;
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:25,代码来源:AssetCompilerBase.cs
示例14: TestInheritance
public void TestInheritance()
{
// -----------------------------------------------------------
// Tests inheritance
// -----------------------------------------------------------
// 4 assets
// [asset1] is referencing [asset2]
// [asset2]
// [asset3] is inheriting [asset1]
// We create a [project1] with [asset1, asset2, asset3]
// Check direct inherit dependencies for [asset3]: [asset1]
// -----------------------------------------------------------
var asset1 = new AssetObjectTest();
var asset2 = new AssetObjectTest();
var assetItem1 = new AssetItem("asset-1", asset1);
var assetItem2 = new AssetItem("asset-2", asset2);
var asset3 = assetItem1.CreateChildAsset();
var assetItem3 = new AssetItem("asset-3", asset3);
asset1.Reference = new AssetReference<AssetObjectTest>(assetItem2.Id, assetItem2.Location);
var project = new Package();
project.Assets.Add(assetItem1);
project.Assets.Add(assetItem2);
project.Assets.Add(assetItem3);
// Create a session with this project
using (var session = new PackageSession(project))
{
var dependencyManager = session.DependencyManager;
// Verify inheritance
{
var assets = dependencyManager.FindAssetsInheritingFrom(asset1.Id);
Assert.AreEqual(1, assets.Count);
Assert.AreEqual(asset3.Id, assets[0].Id);
}
// Remove the inheritance
var copyBase = asset3.Base;
asset3.Base = null;
assetItem3.IsDirty = true;
{
var assets = dependencyManager.FindAssetsInheritingFrom(asset1.Id);
Assert.AreEqual(0, assets.Count);
}
// Add back the inheritance
asset3.Base = copyBase;
assetItem3.IsDirty = true;
{
var assets = dependencyManager.FindAssetsInheritingFrom(asset1.Id);
Assert.AreEqual(1, assets.Count);
Assert.AreEqual(asset3.Id, assets[0].Id);
}
}
}
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:59,代码来源:TestDependencyManager.cs
示例15: AssetLink
// This constructor exists for better factorization of code in AssetDependencies.
// It should not be turned into public as AssetItem is not valid.
internal AssetLink(IContentReference reference, ContentLinkType type)
{
if (reference == null) throw new ArgumentNullException("reference");
Item = null;
this.type = type;
this.reference = reference;
}
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:10,代码来源:AssetLink.cs
示例16: TestSimpleConstruction
public void TestSimpleConstruction()
{
var container = new AssetPropertyGraphContainer(new PackageSession(), new AssetNodeContainer());
var asset = new Types.MyAsset1 { MyString = "String" };
var assetItem = new AssetItem("MyAsset", asset);
var graph = AssetQuantumRegistry.ConstructPropertyGraph(container, assetItem, null);
Assert.IsAssignableFrom<AssetNode>(graph.RootNode);
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:8,代码来源:TestAssetPropertyGraph.cs
示例17: TestSimpleCollectionUpdate
public void TestSimpleCollectionUpdate()
{
var container = new AssetPropertyGraphContainer(new PackageSession(), new AssetNodeContainer());
var asset = new Types.MyAsset2 { MyStrings = { "aaa", "bbb", "ccc" } };
var assetItem = new AssetItem("MyAsset", asset);
var graph = AssetQuantumRegistry.ConstructPropertyGraph(container, assetItem, null);
var node = ((IGraphNode)graph.RootNode).TryGetChild(nameof(Types.MyAsset2.MyStrings));
//var ids = CollectionItemIdHelper.TryGetCollectionItemIds(asset.MyStrings, out itemIds);
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:9,代码来源:TestCollectionUpdates.cs
示例18: ProcessMergeAssetItem
private bool ProcessMergeAssetItem(AssetItem assetItem, HashSet<Guid> beingProcessed)
{
if (beingProcessed.Contains(assetItem.Id))
{
log.Error(package, assetItem.Asset.Base, AssetMessageCode.AssetNotFound, assetItem.Asset.Base);
return false;
}
beingProcessed.Add(assetItem.Id);
AssetItem existingAssetBase = null;
List<AssetBasePart> existingBaseParts = null;
// Process asset base
if (assetItem.Asset.Base != null)
{
if (!ProcessMergeAssetBase(assetItem.Asset.Base, beingProcessed, out existingAssetBase))
{
return false;
}
}
// Process asset base parts
if (assetItem.Asset.BaseParts != null && assetItem.Asset.BaseParts.Count > 0)
{
existingBaseParts = new List<AssetBasePart>();
foreach (var basePart in assetItem.Asset.BaseParts)
{
AssetItem existingAssetBasePart;
if (!ProcessMergeAssetBase(basePart.Base, beingProcessed, out existingAssetBasePart))
{
return false;
}
// Replicate the group with the list of ids
var newBasePart = new AssetBasePart(new AssetBase(existingAssetBasePart.Location, existingAssetBasePart.Asset));
// Instancing ids are copied from existing base part
newBasePart.InstanceIds.AddRange(basePart.InstanceIds);
existingBaseParts.Add(newBasePart);
}
}
// For simple merge (base, newAsset, newBase) => newObject
// For multi-part prefabs merge (base, newAsset, newBase) + baseParts + newBaseParts => newObject
if (!MergeAsset(assetItem, existingAssetBase, existingBaseParts))
{
return false;
}
assetsProcessed.Add(assetItem.Id, assetItem);
assetsToProcess.Remove(assetItem.Id);
return true;
}
开发者ID:hsabaleuski,项目名称:paradox,代码行数:56,代码来源:PackageAssetTemplatingAnalysis.cs
示例19: CreateCompilePackageFromAsset
/// <summary>
/// Create a <see cref="Package"/> that can be used to compile an <see cref="AssetItem"/> by analyzing and resolving its dependencies.
/// </summary>
/// <returns>The package packageSession that can be used to compile the asset item.</returns>
public static Package CreateCompilePackageFromAsset(this PackageSession session, AssetItem originalAssetItem)
{
// create the compile root package and package session
var assetPackageCloned = new Package();
var compilePackageSession = new PackageSession(assetPackageCloned);
AddAssetToCompilePackage(session, originalAssetItem, assetPackageCloned);
return assetPackageCloned;
}
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:14,代码来源:PackageSession.Extensions.cs
示例20: AssetToImportMergeGroup
internal AssetToImportMergeGroup(AssetToImportByImporter parent, AssetItem item)
{
if (parent == null) throw new ArgumentNullException("parent");
if (item == null) throw new ArgumentNullException("item");
this.Parent = parent;
Item = item;
Merges = new List<AssetToImportMerge>();
Enabled = true;
var assetDescription = DisplayAttribute.GetDisplay(item.Asset.GetType());
Log = new LoggerResult(string.Format("Import {0} {1}", assetDescription != null ? assetDescription.Name : "Asset" , item));
}
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:11,代码来源:AssetToImportMergeGroup.cs
注:本文中的AssetItem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论