本文整理汇总了C#中BuildContext.AddAsset方法的典型用法代码示例。如果您正苦于以下问题:C# BuildContext.AddAsset方法的具体用法?C# BuildContext.AddAsset怎么用?C# BuildContext.AddAsset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BuildContext
的用法示例。
在下文中一共展示了BuildContext.AddAsset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
/// <summary>
/// Builds asset
/// </summary>
/// <param name="buildContext"></param>
public override void Build( BuildContext buildContext )
{
string tempFileName = buildContext.GetTempFileName( AssetPath, ".fnt", false );
string tempFileNameR = buildContext.GetTempFileName( AssetPath, ".fnt", true );
string resolvedPath = buildContext.Resolve( SourcePath );
// Launch 'bmfont.com' with temporary output file :
buildContext.RunTool( @"bmfont.com", string.Format("-c \"{0}\" -o \"{1}\"", resolvedPath, tempFileNameR ) );
// load temporary output :
SpriteFont.FontFile font;
using ( var stream = File.OpenRead( tempFileNameR ) ) {
font = SpriteFont.FontLoader.Load( stream );
}
// perform some checks :
if (font.Common.Pages!=1) {
throw new ContentException("Only one page of font image is supported");
}
// patch font description and add children (e.g. "secondary") content :
foreach (var p in font.Pages) {
var newAssetPath = Path.Combine( AssetPath, "Page#" + p.ID.ToString() );
var newSrcPath = Path.Combine( Path.GetDirectoryName(tempFileName), p.File );
if ( Path.GetExtension( newSrcPath ).ToLower() == ".dds" ) {
var asset = buildContext.AddAsset<RawFileAsset>( newAssetPath );
asset.SourceFile = newSrcPath;
asset.BuildOrder = BuildOrder + 1;
} else {
var asset = buildContext.AddAsset<ImageFileTextureAsset>( newAssetPath );
asset.SourceFile = newSrcPath;
asset.BuildOrder = BuildOrder + 1;
}
p.File = newAssetPath;
}
using ( var stream = buildContext.TargetStream( this ) ) {
SpriteFont.FontLoader.Save( stream, font );
}
}