本文整理汇总了C#中BuildContext.RunTool方法的典型用法代码示例。如果您正苦于以下问题:C# BuildContext.RunTool方法的具体用法?C# BuildContext.RunTool怎么用?C# BuildContext.RunTool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BuildContext
的用法示例。
在下文中一共展示了BuildContext.RunTool方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Process
/// <summary>
///
/// </summary>
/// <param name="sourceStream"></param>
/// <param name="targetStream"></param>
public override void Process ( AssetSource assetFile, BuildContext context )
{
string tempFileName = context.GetTempFileName( assetFile.KeyPath, ".fnt" );
string resolvedPath = assetFile.FullSourcePath;
// Launch 'bmfont.com' with temporary output file :
context.RunTool( @"bmfont.com", string.Format("-c \"{0}\" -o \"{1}\"", resolvedPath, tempFileName ) );
// load temporary output :
SpriteFont.FontFile font;
using ( var stream = File.OpenRead( tempFileName ) ) {
font = SpriteFont.FontLoader.Load( stream );
}
// perform some checks :
if (font.Common.Pages!=1) {
throw new BuildException("Only one page of font image is supported");
}
// patch font description and add children (e.g. "secondary") content :
using ( var stream = assetFile.OpenTargetStream() ) {
using ( var sw = new BinaryWriter( stream ) ) {
var xml = SpriteFont.FontLoader.SaveToString( font );
sw.Write( xml );
// write pages :
foreach (var p in font.Pages) {
var pageFile = Path.Combine( Path.GetDirectoryName( tempFileName ), p.File );
if ( Path.GetExtension( pageFile ).ToLower() == ".dds" ) {
context.CopyFileTo( pageFile, sw );
} else {
TextureProcessor.RunNVCompress( context, pageFile, pageFile + ".dds", true, false, false, true, true, false, TextureProcessor.TextureCompression.RGB );
context.CopyFileTo( pageFile + ".dds", sw );
}
}
}
}
}
示例2: 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 );
}
}
示例3: Build
/// <summary>
/// Builds asset
/// </summary>
/// <param name="buildContext"></param>
public override void Build ( BuildContext buildContext )
{
var resolvedPath = buildContext.Resolve( SourceFile );
var destPath = buildContext.GetTempFileName( Hash, ".scene" );
var cmdLine = string.Format("\"{0}\" /out:\"{1}\" /merge:{2} {4} {5}",
resolvedPath, destPath,
MergeTolerance,
null,
ImportAnimation ? "/anim":"",
ImportGeometry ? "/geom":""
);
buildContext.RunTool( "Native.Fbx.exe", cmdLine );
using ( var target = buildContext.OpenTargetStream( this ) ) {
buildContext.CopyTo( destPath, target );
}
}
示例4: Process
/// <summary>
///
/// </summary>
/// <param name="sourceStream"></param>
/// <param name="targetStream"></param>
public override void Process ( AssetSource assetFile, BuildContext context )
{
var resolvedPath = assetFile.FullSourcePath;
var destPath = context.GetTempFileName( assetFile.KeyPath, ".scene" );
var cmdLine = string.Format("\"{0}\" /out:\"{1}\" /base:\"{2}\" /merge:{3} {4} {5} {6} {7}",
resolvedPath,
destPath,
assetFile.BaseDirectory,
MergeTolerance,
ImportAnimation ? "/anim":"",
ImportGeometry ? "/geom":"",
OutputReport ? "/report":"" ,
GenerateMissingMaterials ? "/genmtrl":""
);
context.RunTool( "FScene.exe", cmdLine );
using ( var target = assetFile.OpenTargetStream() ) {
context.CopyFileTo( destPath, target );
}
}
示例5: RunFxc
/// <summary>
///
/// </summary>
/// <param name="sourceFile"></param>
/// <param name="profile"></param>
/// <param name="entryPoint"></param>
/// <param name="defines"></param>
/// <returns></returns>
byte[] RunFxc ( BuildContext buildContext, string sourceFile, string profile, string entryPoint, string defines, string output, string listing )
{
StringBuilder sb = new StringBuilder();
sb.Append("/Cc" + " ");
sb.Append("/T" + profile + " ");
sb.Append("/E" + entryPoint + " ");
sb.Append("/Fo\"" + output + "\" ");
sb.Append("/Fc\"" + listing + "\" ");
sb.Append("/nologo" + " ");
sb.Append("/O" + OptimizationLevel.ToString() + " ");
if ( DisableOptimization) sb.Append("/Od ");
if ( PreferFlowControl) sb.Append("/Gfp ");
if ( AvoidFlowControl) sb.Append("/Gfa ");
if ( MatrixPacking==ShaderMatrixPacking.ColumnMajor ) sb.Append("/Zpc ");
if ( MatrixPacking==ShaderMatrixPacking.RowMajor ) sb.Append("/Zpr ");
foreach ( var def in defines.Split(new[]{' ','\t'}, StringSplitOptions.RemoveEmptyEntries) ) {
sb.AppendFormat("/D{0}=1 ", def);
}
sb.Append("\"" + sourceFile + "\"");
try {
buildContext.RunTool("fxc_1.exe", sb.ToString());
} catch ( ToolException tx ) {
/// entry point not fount - that is ok.
if (tx.Message.Contains("error X3501")) {
Log.Debug("No entry point '{0}'. That is ok.", entryPoint );
return new byte[0];
}
throw;
}
return File.ReadAllBytes( output );
}
示例6: RunNVCompress
internal static void RunNVCompress( BuildContext buildContext, string src, string dst, bool noMips, bool fast, bool toNormal, bool color, bool alpha, bool normal, TextureCompression compression )
{
string commandLine = "";
if ( noMips ) commandLine += " -nomips" ;
if ( fast ) commandLine += " -fast" ;
if ( toNormal ) commandLine += " -tonormal";
if ( color ) commandLine += " -color" ;
if ( alpha ) commandLine += " -alpha" ;
if ( normal ) commandLine += " -normal" ;
commandLine += ( " -" + compression.ToString().ToLower() );
commandLine += ( " \"" + src + "\"" );
commandLine += ( " \"" + dst + "\"" );
buildContext.RunTool( @"nvcompress.exe", commandLine );//*/
}