当前位置: 首页>>代码示例>>C#>>正文


C# BuildContext.RunTool方法代码示例

本文整理汇总了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 );

						}
					}
				}
			}
		}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:56,代码来源:FontProcessor.cs

示例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 );
            }
        }
开发者ID:temik911,项目名称:audio,代码行数:50,代码来源:BMFontSpriteFontAsset.cs

示例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 );
			}
		}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:22,代码来源:FbxFileSceneAsset.cs

示例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 );
			}
		}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:27,代码来源:SceneProcessor.cs

示例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 );
		}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:49,代码来源:UbershaderProcessor.cs

示例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 );//*/
        }
开发者ID:temik911,项目名称:audio,代码行数:17,代码来源:ImageFileTextureAsset.cs


注:本文中的BuildContext.RunTool方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。