本文整理汇总了C#中BuildContext.GetTempFileName方法的典型用法代码示例。如果您正苦于以下问题:C# BuildContext.GetTempFileName方法的具体用法?C# BuildContext.GetTempFileName怎么用?C# BuildContext.GetTempFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BuildContext
的用法示例。
在下文中一共展示了BuildContext.GetTempFileName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 );
}
}
示例2: Process
/// <summary>
///
/// </summary>
/// <param name="sourceStream"></param>
/// <param name="targetStream"></param>
public override void Process ( AssetSource assetFile, BuildContext context )
{
var src = assetFile.FullSourcePath;
var dst = context.GetTempFileName( assetFile.KeyPath, ".dds" );
RunNVCompress( context, src, dst, NoMips, Fast, ToNormal, Color, Alpha, Normal, Compression );
using ( var target = assetFile.OpenTargetStream() ) {
context.CopyFileTo( dst, target );
}
}
示例3: 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 );
}
}
}
}
}
示例4: 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 );
}
}
示例5: 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 );
}
}
示例6: Process
/// <summary>
///
/// </summary>
/// <param name="buildContext"></param>
public override void Process ( AssetSource assetFile, BuildContext buildContext )
{
//
// Get combinations :
//
string shaderSource = File.ReadAllText( assetFile.FullSourcePath );
var ubershaderDecl = shaderSource.Split( new[]{Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries )
.Select( line0 => line0.Trim() )
.Where( line1 => line1.StartsWith("$ubershader") )
.ToList();
var defineList = new List<string>();
foreach ( var comb in ubershaderDecl ) {
var ue = new UbershaderEnumerator( comb, "$ubershader" );
defineList.AddRange( ue.DefineList );
}
//
// Start listing builder :
//
ListingPath = buildContext.GetTempFileName( assetFile.KeyPath, ".html" );
var htmlBuilder = new StringBuilder();
htmlBuilder.AppendFormat("<pre>");
htmlBuilder.AppendLine("<b>Ubershader assembly listing</b>");
htmlBuilder.AppendLine("");
htmlBuilder.AppendLine("<b>Source:</b> <i>" + assetFile.KeyPath + "</i>" );
htmlBuilder.AppendLine("");
// insert includes here bit later:
var includeInsert = htmlBuilder.Length;
htmlBuilder.AppendLine("<b>Declarations:</b>");
foreach ( var comb in ubershaderDecl ) {
htmlBuilder.AppendLine(" <i>" + comb + "</i>");
}
htmlBuilder.AppendLine("");
var usdb = new List<UsdbEntry>();
var include = new IncludeHandler(buildContext);
//
// Build all :
//
foreach ( var defines in defineList ) {
var id = defineList.IndexOf( defines );
var psbc = buildContext.GetTempFileName( assetFile.KeyPath, "." + id.ToString("D8") + ".PS.dxbc" );
var vsbc = buildContext.GetTempFileName( assetFile.KeyPath, "." + id.ToString("D8") + ".VS.dxbc" );
var gsbc = buildContext.GetTempFileName( assetFile.KeyPath, "." + id.ToString("D8") + ".GS.dxbc" );
var hsbc = buildContext.GetTempFileName( assetFile.KeyPath, "." + id.ToString("D8") + ".HS.dxbc" );
var dsbc = buildContext.GetTempFileName( assetFile.KeyPath, "." + id.ToString("D8") + ".DS.dxbc" );
var csbc = buildContext.GetTempFileName( assetFile.KeyPath, "." + id.ToString("D8") + ".CS.dxbc" );
var pshtm = buildContext.GetTempFileName( assetFile.KeyPath, "." + id.ToString("D8") + ".PS.html" );
var vshtm = buildContext.GetTempFileName( assetFile.KeyPath, "." + id.ToString("D8") + ".VS.html" );
var gshtm = buildContext.GetTempFileName( assetFile.KeyPath, "." + id.ToString("D8") + ".GS.html" );
var hshtm = buildContext.GetTempFileName( assetFile.KeyPath, "." + id.ToString("D8") + ".HS.html" );
var dshtm = buildContext.GetTempFileName( assetFile.KeyPath, "." + id.ToString("D8") + ".DS.html" );
var cshtm = buildContext.GetTempFileName( assetFile.KeyPath, "." + id.ToString("D8") + ".CS.html" );
var ps = Compile( buildContext, include, shaderSource, assetFile.FullSourcePath, "ps_5_0", PSEntryPoint, defines, psbc, pshtm );
var vs = Compile( buildContext, include, shaderSource, assetFile.FullSourcePath, "vs_5_0", VSEntryPoint, defines, vsbc, vshtm );
var gs = Compile( buildContext, include, shaderSource, assetFile.FullSourcePath, "gs_5_0", GSEntryPoint, defines, gsbc, gshtm );
var hs = Compile( buildContext, include, shaderSource, assetFile.FullSourcePath, "hs_5_0", HSEntryPoint, defines, hsbc, hshtm );
var ds = Compile( buildContext, include, shaderSource, assetFile.FullSourcePath, "ds_5_0", DSEntryPoint, defines, dsbc, dshtm );
var cs = Compile( buildContext, include, shaderSource, assetFile.FullSourcePath, "cs_5_0", CSEntryPoint, defines, csbc, cshtm );
htmlBuilder.AppendFormat( (vs.Length==0) ? ".. " : "<a href=\"{0}\">vs</a> ", Path.GetFileName(vshtm) );
htmlBuilder.AppendFormat( (ps.Length==0) ? ".. " : "<a href=\"{0}\">ps</a> ", Path.GetFileName(pshtm) );
htmlBuilder.AppendFormat( (hs.Length==0) ? ".. " : "<a href=\"{0}\">hs</a> ", Path.GetFileName(hshtm) );
htmlBuilder.AppendFormat( (ds.Length==0) ? ".. " : "<a href=\"{0}\">ds</a> ", Path.GetFileName(dshtm) );
htmlBuilder.AppendFormat( (gs.Length==0) ? ".. " : "<a href=\"{0}\">gs</a> ", Path.GetFileName(gshtm) );
htmlBuilder.AppendFormat( (cs.Length==0) ? ".. " : "<a href=\"{0}\">cs</a> ", Path.GetFileName(cshtm) );
htmlBuilder.Append( "[" + defines + "]<br>" );
usdb.Add( new UsdbEntry( defines, ps, vs, gs, hs, ds, cs ) );
}
htmlBuilder.Insert( includeInsert,
"<b>Includes:</b>\r\n"
+ string.Join("", include.Includes.Select(s=>" <i>" + s + "</i>\r\n") )
+ "\r\n");
//.........这里部分代码省略.........
示例7: Build
/// <summary>
///
/// </summary>
/// <param name="buildContext"></param>
public override void Build ( BuildContext buildContext )
{
//
// Get combinations :
//
var combDecl = File.ReadAllLines( buildContext.Resolve( SourceFile ) )
.Where( line0 => line0.Trim().StartsWith("$ubershader") )
.ToList();
var defineList = new List<string>();
foreach ( var comb in combDecl ) {
var ue = new UbershaderEnumerator( comb.Trim(), "$ubershader" );
defineList.AddRange( ue.DefineList );
}
//
// Start listing builder :
//
ListingPath = buildContext.GetTempFileName( AssetPath, ".html" );
var htmlBuilder = new StringBuilder();
htmlBuilder.AppendFormat("<pre>");
htmlBuilder.AppendLine("<b>Ubershader assembly listing</b>");
htmlBuilder.AppendLine("");
htmlBuilder.AppendLine("<b>Source:</b> <i>" + AssetPath + "</i>" );
htmlBuilder.AppendLine("");
htmlBuilder.AppendLine("<b>Declarations:</b>");
foreach ( var comb in combDecl ) {
htmlBuilder.AppendLine(" <i>" + comb + "</i>");
}
htmlBuilder.AppendLine("");
var usdb = new List<UsdbEntry>();
//
// Build all :
//
foreach ( var defines in defineList ) {
var id = defineList.IndexOf( defines );
var psbc = buildContext.GetTempFileName(AssetPath, "." + id.ToString("D4") + ".PS.dxbc" );
var vsbc = buildContext.GetTempFileName(AssetPath, "." + id.ToString("D4") + ".VS.dxbc" );
var gsbc = buildContext.GetTempFileName(AssetPath, "." + id.ToString("D4") + ".GS.dxbc" );
var hsbc = buildContext.GetTempFileName(AssetPath, "." + id.ToString("D4") + ".HS.dxbc" );
var dsbc = buildContext.GetTempFileName(AssetPath, "." + id.ToString("D4") + ".DS.dxbc" );
var csbc = buildContext.GetTempFileName(AssetPath, "." + id.ToString("D4") + ".CS.dxbc" );
var pshtm = buildContext.GetTempFileName(AssetPath, "." + id.ToString("D4") + ".PS.html" );
var vshtm = buildContext.GetTempFileName(AssetPath, "." + id.ToString("D4") + ".VS.html" );
var gshtm = buildContext.GetTempFileName(AssetPath, "." + id.ToString("D4") + ".GS.html" );
var hshtm = buildContext.GetTempFileName(AssetPath, "." + id.ToString("D4") + ".HS.html" );
var dshtm = buildContext.GetTempFileName(AssetPath, "." + id.ToString("D4") + ".DS.html" );
var cshtm = buildContext.GetTempFileName(AssetPath, "." + id.ToString("D4") + ".CS.html" );
var ps = Compile( buildContext, SourceFile, "ps_5_0", PSEntryPoint, defines, psbc, pshtm );
var vs = Compile( buildContext, SourceFile, "vs_5_0", VSEntryPoint, defines, vsbc, vshtm );
var gs = Compile( buildContext, SourceFile, "gs_5_0", GSEntryPoint, defines, gsbc, gshtm );
var hs = Compile( buildContext, SourceFile, "hs_5_0", HSEntryPoint, defines, hsbc, hshtm );
var ds = Compile( buildContext, SourceFile, "ds_5_0", DSEntryPoint, defines, dsbc, dshtm );
var cs = Compile( buildContext, SourceFile, "cs_5_0", CSEntryPoint, defines, csbc, cshtm );
htmlBuilder.AppendFormat( (vs.Length==0) ? ".. " : "<a href=\"{0}\">vs</a> ", Path.GetFileName(vshtm) );
htmlBuilder.AppendFormat( (ps.Length==0) ? ".. " : "<a href=\"{0}\">ps</a> ", Path.GetFileName(pshtm) );
htmlBuilder.AppendFormat( (hs.Length==0) ? ".. " : "<a href=\"{0}\">hs</a> ", Path.GetFileName(hshtm) );
htmlBuilder.AppendFormat( (ds.Length==0) ? ".. " : "<a href=\"{0}\">ds</a> ", Path.GetFileName(dshtm) );
htmlBuilder.AppendFormat( (gs.Length==0) ? ".. " : "<a href=\"{0}\">gs</a> ", Path.GetFileName(gshtm) );
htmlBuilder.AppendFormat( (cs.Length==0) ? ".. " : "<a href=\"{0}\">cs</a> ", Path.GetFileName(cshtm) );
htmlBuilder.Append( "[" + defines + "]<br>" );
usdb.Add( new UsdbEntry( defines, ps, vs, gs, hs, ds, cs ) );
}
File.WriteAllText( buildContext.GetTempFileName(AssetPath, ".html"), htmlBuilder.ToString() );
//
// Write ubershader :
//
using ( var fs = buildContext.OpenTargetStream( this ) ) {
using ( var bw = new BinaryWriter( fs ) ) {
bw.Write( new[]{'U','S','D','B'});
bw.Write( usdb.Count );
foreach ( var entry in usdb ) {
bw.Write( entry.Defines );
//.........这里部分代码省略.........
示例8: Process
/// <summary>
///
/// </summary>
/// <param name="buildContext"></param>
public override void Process ( AssetSource assetFile, BuildContext context )
{
var fileDir = Path.GetDirectoryName( assetFile.FullSourcePath );
var fileNames = File.ReadAllLines(assetFile.FullSourcePath)
.Select( f1 => f1.Trim() )
.Where( f2 => !f2.StartsWith("#") && !string.IsNullOrWhiteSpace(f2) )
.Select( f3 => Path.Combine( fileDir, f3 ) )
.ToArray();
var depNames = File.ReadAllLines(assetFile.FullSourcePath)
.Select( f1 => f1.Trim() )
.Where( f2 => !f2.StartsWith("#") && !string.IsNullOrWhiteSpace(f2) )
.Select( f3 => Path.Combine( Path.GetDirectoryName(assetFile.KeyPath), f3 ) )
.ToArray();
var images = fileNames
.Select( fn => LoadImage( fn ) )
.OrderByDescending( img0 => img0.Width * img0.Height )
.ThenByDescending( img1 => img1.Width )
.ThenByDescending( img2 => img2.Height )
.ToList();
if (!images.Any()) {
throw new InvalidOperationException("At least one subimage must be added to the texture atlas");
}
//
// Pack atlas :
//
AtlasNode root = new AtlasNode(0,0, Width, Height, Padding );
foreach ( var img in images ) {
var n = root.Insert( img );
if (n==null) {
throw new InvalidOperationException("No enough room to place image");
}
}
//
// Create image and fill it with atlas elements :
//
var targetImage = new Image( Width, Height );
targetImage.Fill( FillColor );
root.WriteImages( targetImage );
//
// Save and compress :
//
var tgaOutput = context.GetTempFileName( assetFile.KeyPath, ".tga" );
var ddsOutput = context.GetTempFileName( assetFile.KeyPath, ".dds" );
Image.SaveTga( targetImage, tgaOutput );
var compression = UseDXT ? TextureProcessor.TextureCompression.BC3 : TextureProcessor.TextureCompression.RGB;
TextureProcessor.RunNVCompress( context, tgaOutput, ddsOutput, NoMips, false, false, true, true, false, compression );
//
// Write binary blob (text + dds texture):
//
using ( var fs = assetFile.OpenTargetStream(depNames) ) {
var bw = new BinaryWriter( fs );
bw.Write(new[]{'A','T','L','S'});
bw.Write( images.Count );
root.WriteLayout( bw );
bw.Write( (int)(new FileInfo(ddsOutput).Length) );
using ( var dds = File.OpenRead( ddsOutput ) ) {
dds.CopyTo( fs );
}
}
}
示例9: Build
/// <summary>
///
/// </summary>
/// <param name="buildContext"></param>
public override void Build ( BuildContext buildContext )
{
var fileNames = buildContext.ExpandAndResolveSearchPatterns( Dependencies );
var images = fileNames
.Select( fn => Image.LoadTga( fn ) )
.OrderByDescending( img0 => img0.Width * img0.Height )
.ThenByDescending( img1 => img1.Width )
.ThenByDescending( img2 => img2.Height )
.ToList();
if (!images.Any()) {
throw new InvalidOperationException("At least one subimage must be added to teh texture atlas");
}
//
// Pack atlas :
//
AtlasNode root = new AtlasNode(0,0, Width, Height, Padding );
foreach ( var img in images ) {
var n = root.Insert( img );
if (n==null) {
throw new InvalidOperationException("No enough room to place image");
}
}
//
// Create image and fill it with atlas elements :
//
var targetImage = new Image( Width, Height );
targetImage.Fill( FillColor );
root.WriteImages( targetImage );
//
// Save and compress :
//
var tgaOutput = buildContext.GetTempFileName( AssetPath, ".tga" );
var ddsOutput = buildContext.GetTempFileName( AssetPath, ".dds" );
Image.SaveTga( targetImage, tgaOutput );
var compression = UseDXT ? ImageFileTextureAsset.TextureCompression.BC3 : ImageFileTextureAsset.TextureCompression.RGB;
ImageFileTextureAsset.RunNVCompress( buildContext, tgaOutput, ddsOutput, NoMips, false, false, true, true, false, compression );
//
// Write binary blob (text + dds texture):
//
using ( var fs = buildContext.OpenTargetStream( this ) ) {
var bw = new BinaryWriter( fs );
bw.Write(new[]{'A','T','L','S'});
bw.Write( images.Count );
root.WriteLayout( bw );
bw.Write( (int)(new FileInfo(ddsOutput).Length) );
using ( var dds = File.OpenRead( ddsOutput ) ) {
dds.CopyTo( fs );
}
}
}
示例10: Build
public override void Build( BuildContext buildContext )
{
var src = buildContext.Resolve( SourceFile );
var dst = buildContext.GetTempFileName( Hash, ".dds", true );
RunNVCompress( buildContext, src, dst, NoMips, Fast, ToNormal, Color, Alpha, Normal, Compression );
using ( var target = buildContext.TargetStream( this ) ) {
buildContext.CopyTo( dst, target );
}
}