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


C# BuildContext.TargetStream方法代码示例

本文整理汇总了C#中BuildContext.TargetStream方法的典型用法代码示例。如果您正苦于以下问题:C# BuildContext.TargetStream方法的具体用法?C# BuildContext.TargetStream怎么用?C# BuildContext.TargetStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BuildContext的用法示例。


在下文中一共展示了BuildContext.TargetStream方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 );
            }
        }
开发者ID:temik911,项目名称:audio,代码行数:50,代码来源:BMFontSpriteFontAsset.cs

示例2: Build

 /// <summary>
 /// 
 /// </summary>
 /// <param name="buildContext"></param>
 public override void Build( BuildContext buildContext )
 {
     using ( var target = buildContext.TargetStream( this ) ) {
         buildContext.CopyTo( SourceFile, target );
     }
 }
开发者ID:temik911,项目名称:audio,代码行数:10,代码来源:RawFileAsset.cs

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

示例4: Build

 /// <summary>
 /// 
 /// </summary>
 /// <param name="buildContext"></param>
 public override void Build( BuildContext buildContext )
 {
     Misc.SaveObjectToXml( this, GetType(), buildContext.TargetStream( this ) );
 }
开发者ID:temik911,项目名称:audio,代码行数:8,代码来源:AbstractAsset.cs

示例5: 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", true );
            var ddsOutput	=	buildContext.GetTempFileName( AssetPath, ".dds", true );
            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.TargetStream( 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 );
                }
            }
        }
开发者ID:temik911,项目名称:audio,代码行数:66,代码来源:AssembledTextureAtlasAsset.cs

示例6: 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", true );
            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", true );
                var vsbc	=	buildContext.GetTempFileName(AssetPath, "." + id.ToString("D4") + ".VS.dxbc", true );
                var gsbc	=	buildContext.GetTempFileName(AssetPath, "." + id.ToString("D4") + ".GS.dxbc", true );
                var hsbc	=	buildContext.GetTempFileName(AssetPath, "." + id.ToString("D4") + ".HS.dxbc", true );
                var dsbc	=	buildContext.GetTempFileName(AssetPath, "." + id.ToString("D4") + ".DS.dxbc", true );
                var csbc	=	buildContext.GetTempFileName(AssetPath, "." + id.ToString("D4") + ".CS.dxbc", true );

                var pshtm	=	buildContext.GetTempFileName(AssetPath, "." + id.ToString("D4") + ".PS.html", true );
                var vshtm	=	buildContext.GetTempFileName(AssetPath, "." + id.ToString("D4") + ".VS.html", true );
                var gshtm	=	buildContext.GetTempFileName(AssetPath, "." + id.ToString("D4") + ".GS.html", true );
                var hshtm	=	buildContext.GetTempFileName(AssetPath, "." + id.ToString("D4") + ".HS.html", true );
                var dshtm	=	buildContext.GetTempFileName(AssetPath, "." + id.ToString("D4") + ".DS.html", true );
                var cshtm	=	buildContext.GetTempFileName(AssetPath, "." + id.ToString("D4") + ".CS.html", true );

                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", true), htmlBuilder.ToString() );

            //
            //	Write ubershader :
            //
            using ( var fs = buildContext.TargetStream( 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 );

                        bw.Write( new[]{'P','S','B','C'});
                        bw.Write( entry.PSBytecode.Length );
                        bw.Write( entry.PSBytecode );
//.........这里部分代码省略.........
开发者ID:temik911,项目名称:audio,代码行数:101,代码来源:UbershaderAsset.cs

示例7: 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", true );
            var cmdLine			=	string.Format("\"{0}\" /out:\"{1}\" /merge:{2} /base:\"{3}\" {4} {5}",
                resolvedPath, destPath,
                MergeTolerance,
                buildContext.ContentDirectory,
                ImportAnimation ? "/anim":"",
                ImportGeometry ? "/geom":""
            );

            buildContext.RunTool( "FbxTool.exe", cmdLine );

            using ( var target = buildContext.TargetStream( this ) ) {
                buildContext.CopyTo( destPath, target );
            }
        }
开发者ID:temik911,项目名称:audio,代码行数:22,代码来源:FbxFileSceneAsset.cs


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