Пример #1
0
        public void CopyToTarget(tk2dSpriteCollection target)
        {
            target.textureParams = textureParams.ToArray();
            target.spriteSheets  = spriteSheets.ToArray();
            target.fonts         = fonts.ToArray();

            var source = this;

            target.platforms = new List <tk2dSpriteCollectionPlatform>();
            foreach (tk2dSpriteCollectionPlatform plat in source.platforms)
            {
                tk2dSpriteCollectionPlatform p = new tk2dSpriteCollectionPlatform();
                p.CopyFrom(plat);
                target.platforms.Add(p);
            }
            target.assetName = source.assetName;
            target.loadable  = source.loadable;

            target.maxTextureSize      = source.maxTextureSize;
            target.forceTextureSize    = source.forceTextureSize;
            target.forcedTextureWidth  = source.forcedTextureWidth;
            target.forcedTextureHeight = source.forcedTextureHeight;

            target.textureCompression   = source.textureCompression;
            target.atlasWidth           = source.atlasWidth;
            target.atlasHeight          = source.atlasHeight;
            target.forceSquareAtlas     = source.forceSquareAtlas;
            target.atlasWastage         = source.atlasWastage;
            target.allowMultipleAtlases = source.allowMultipleAtlases;

            target.spriteCollection   = source.spriteCollection;
            target.premultipliedAlpha = source.premultipliedAlpha;

            CopyArray(ref target.altMaterials, source.altMaterials);
            CopyArray(ref target.atlasMaterials, source.atlasMaterials);
            CopyArray(ref target.atlasTextures, source.atlasTextures);

            target.useTk2dCamera        = source.useTk2dCamera;
            target.targetHeight         = source.targetHeight;
            target.targetOrthoSize      = source.targetOrthoSize;
            target.globalScale          = source.globalScale;
            target.physicsDepth         = source.physicsDepth;
            target.disableTrimming      = source.disableTrimming;
            target.normalGenerationMode = source.normalGenerationMode;
            target.padAmount            = source.padAmount;
            target.autoUpdate           = source.autoUpdate;
            target.editorDisplayScale   = source.editorDisplayScale;

            // Texture settings
            target.filterMode = source.filterMode;
            target.wrapMode   = source.wrapMode;
            target.userDefinedTextureSettings = source.userDefinedTextureSettings;
            target.mipmapEnabled = source.mipmapEnabled;
            target.anisoLevel    = source.anisoLevel;
        }
        public void CopyFromSource(bool copyBuilt)
        {
            this.obj.Upgrade();             // make sure its up to date

            textureParams = new List <tk2dSpriteCollectionDefinition>(obj.textureParams.Length);
            foreach (var v in obj.textureParams)
            {
                if (v == null)
                {
                    textureParams.Add(null);
                }
                else
                {
                    var t = new tk2dSpriteCollectionDefinition();
                    t.CopyFrom(v);
                    textureParams.Add(t);
                }
            }

            spriteSheets = new List <tk2dSpriteSheetSource>();
            if (obj.spriteSheets != null)
            {
                foreach (var v in obj.spriteSheets)
                {
                    if (v == null)
                    {
                        spriteSheets.Add(null);
                    }
                    else
                    {
                        var t = new tk2dSpriteSheetSource();
                        t.CopyFrom(v);
                        spriteSheets.Add(t);
                    }
                }
            }

            fonts = new List <tk2dSpriteCollectionFont>();
            if (obj.fonts != null)
            {
                foreach (var v in obj.fonts)
                {
                    if (v == null)
                    {
                        fonts.Add(null);
                    }
                    else
                    {
                        var t = new tk2dSpriteCollectionFont();
                        t.CopyFrom(v);
                        fonts.Add(t);
                    }
                }
            }

            attachPointTestSprites.Clear();
            foreach (var v in obj.attachPointTestSprites)
            {
                if (v.spriteCollection != null && v.spriteCollection.IsValidSpriteId(v.spriteId))
                {
                    tk2dSpriteCollection.AttachPointTestSprite ap = new tk2dSpriteCollection.AttachPointTestSprite();
                    ap.CopyFrom(v);
                    attachPointTestSprites[v.attachPointName] = v;
                }
            }

            UpgradeLegacySpriteSheets();

            var target = this;
            var source = obj;

            target.platforms = new List <tk2dSpriteCollectionPlatform>();
            foreach (tk2dSpriteCollectionPlatform plat in source.platforms)
            {
                tk2dSpriteCollectionPlatform p = new tk2dSpriteCollectionPlatform();
                p.CopyFrom(plat);
                target.platforms.Add(p);
            }
            if (target.platforms.Count == 0)
            {
                tk2dSpriteCollectionPlatform plat = new tk2dSpriteCollectionPlatform();                 // add a null platform
                target.platforms.Add(plat);
            }

            target.assetName   = source.assetName;
            target.loadable    = source.loadable;
            target.atlasFormat = source.atlasFormat;

            target.maxTextureSize      = source.maxTextureSize;
            target.forceTextureSize    = source.forceTextureSize;
            target.forcedTextureWidth  = source.forcedTextureWidth;
            target.forcedTextureHeight = source.forcedTextureHeight;

            target.textureCompression   = source.textureCompression;
            target.atlasWidth           = source.atlasWidth;
            target.atlasHeight          = source.atlasHeight;
            target.forceSquareAtlas     = source.forceSquareAtlas;
            target.atlasWastage         = source.atlasWastage;
            target.allowMultipleAtlases = source.allowMultipleAtlases;
            target.disableRotation      = source.disableRotation;
            target.removeDuplicates     = source.removeDuplicates;
            target.allowSpannedDicing   = source.allowSpannedDicing;

            target.premultipliedAlpha = source.premultipliedAlpha;

            target.sizeDef.CopyFrom(source.sizeDef);
            target.globalScale          = source.globalScale;
            target.globalTextureRescale = source.globalTextureRescale;
            target.physicsDepth         = source.physicsDepth;
            target.physicsEngine        = source.physicsEngine;
            target.disableTrimming      = source.disableTrimming;
            target.normalGenerationMode = source.normalGenerationMode;
            target.padAmount            = source.padAmount;
            target.autoUpdate           = source.autoUpdate;
            target.editorDisplayScale   = source.editorDisplayScale;

            // Texture settings
            target.filterMode = source.filterMode;
            target.wrapMode   = source.wrapMode;
            target.userDefinedTextureSettings = source.userDefinedTextureSettings;
            target.mipmapEnabled = source.mipmapEnabled;
            target.anisoLevel    = source.anisoLevel;

            target.linkedSpriteCollections.Clear();
            for (int i = 0; i < source.linkedSpriteCollections.Count; ++i)
            {
                tk2dLinkedSpriteCollection t = new tk2dLinkedSpriteCollection();
                t.name             = source.linkedSpriteCollections[i].name;
                t.spriteCollection = source.linkedSpriteCollections[i].spriteCollection;
                target.linkedSpriteCollections.Add(t);
            }

            if (copyBuilt)
            {
                CopyBuiltFromSource(source);
            }
        }
        public void CopyToTarget(tk2dSpriteCollection target)
        {
            target.textureParams = textureParams.ToArray();
            target.spriteSheets  = spriteSheets.ToArray();
            target.fonts         = fonts.ToArray();

            var source = this;

            target.platforms = new List <tk2dSpriteCollectionPlatform>();
            foreach (tk2dSpriteCollectionPlatform plat in source.platforms)
            {
                tk2dSpriteCollectionPlatform p = new tk2dSpriteCollectionPlatform();
                p.CopyFrom(plat);
                target.platforms.Add(p);
            }
            target.assetName   = source.assetName;
            target.loadable    = source.loadable;
            target.atlasFormat = source.atlasFormat;

            target.maxTextureSize      = source.maxTextureSize;
            target.forceTextureSize    = source.forceTextureSize;
            target.forcedTextureWidth  = source.forcedTextureWidth;
            target.forcedTextureHeight = source.forcedTextureHeight;

            target.textureCompression   = source.textureCompression;
            target.atlasWidth           = source.atlasWidth;
            target.atlasHeight          = source.atlasHeight;
            target.forceSquareAtlas     = source.forceSquareAtlas;
            target.atlasWastage         = source.atlasWastage;
            target.allowMultipleAtlases = source.allowMultipleAtlases;
            target.disableRotation      = source.disableRotation;
            target.removeDuplicates     = source.removeDuplicates;
            target.allowSpannedDicing   = source.allowSpannedDicing;

            target.spriteCollection   = source.spriteCollection;
            target.premultipliedAlpha = source.premultipliedAlpha;

            CopyArray(ref target.altMaterials, source.altMaterials);
            CopyArray(ref target.atlasMaterials, source.atlasMaterials);
            CopyArray(ref target.atlasTextures, source.atlasTextures);
            CopyArray(ref target.atlasTextureFiles, source.atlasTextureFiles);

            target.sizeDef.CopyFrom(source.sizeDef);
            target.globalScale          = source.globalScale;
            target.globalTextureRescale = source.globalTextureRescale;
            target.physicsDepth         = source.physicsDepth;
            target.physicsEngine        = source.physicsEngine;
            target.disableTrimming      = source.disableTrimming;
            target.normalGenerationMode = source.normalGenerationMode;
            target.padAmount            = source.padAmount;
            target.autoUpdate           = source.autoUpdate;
            target.editorDisplayScale   = source.editorDisplayScale;

            // Texture settings
            target.filterMode = source.filterMode;
            target.wrapMode   = source.wrapMode;
            target.userDefinedTextureSettings = source.userDefinedTextureSettings;
            target.mipmapEnabled = source.mipmapEnabled;
            target.anisoLevel    = source.anisoLevel;

            // Attach point test data
            // Make sure we only store relevant data
            HashSet <string> attachPointNames = new HashSet <string>();

            foreach (tk2dSpriteCollectionDefinition def in textureParams)
            {
                foreach (tk2dSpriteDefinition.AttachPoint ap in def.attachPoints)
                {
                    attachPointNames.Add(ap.name);
                }
            }
            target.attachPointTestSprites.Clear();
            foreach (string name in attachPointTestSprites.Keys)
            {
                if (attachPointNames.Contains(name))
                {
                    tk2dSpriteCollection.AttachPointTestSprite lut = new tk2dSpriteCollection.AttachPointTestSprite();
                    lut.CopyFrom(attachPointTestSprites[name]);
                    lut.attachPointName = name;
                    target.attachPointTestSprites.Add(lut);
                }
            }

            target.linkedSpriteCollections.Clear();
            for (int i = 0; i < source.linkedSpriteCollections.Count; ++i)
            {
                tk2dLinkedSpriteCollection t = new tk2dLinkedSpriteCollection();
                t.name             = source.linkedSpriteCollections[i].name;
                t.spriteCollection = source.linkedSpriteCollections[i].spriteCollection;
                target.linkedSpriteCollections.Add(t);
            }
        }
Пример #4
0
        public void CopyFromSource()
        {
            this.obj.Upgrade();             // make sure its up to date

            textureParams = new List <tk2dSpriteCollectionDefinition>(obj.textureParams.Length);
            foreach (var v in obj.textureParams)
            {
                if (v == null)
                {
                    textureParams.Add(null);
                }
                else
                {
                    var t = new tk2dSpriteCollectionDefinition();
                    t.CopyFrom(v);
                    textureParams.Add(t);
                }
            }

            spriteSheets = new List <tk2dSpriteSheetSource>();
            if (obj.spriteSheets != null)
            {
                foreach (var v in obj.spriteSheets)
                {
                    if (v == null)
                    {
                        spriteSheets.Add(null);
                    }
                    else
                    {
                        var t = new tk2dSpriteSheetSource();
                        t.CopyFrom(v);
                        spriteSheets.Add(t);
                    }
                }
            }

            fonts = new List <tk2dSpriteCollectionFont>();
            if (obj.fonts != null)
            {
                foreach (var v in obj.fonts)
                {
                    if (v == null)
                    {
                        fonts.Add(null);
                    }
                    else
                    {
                        var t = new tk2dSpriteCollectionFont();
                        t.CopyFrom(v);
                        fonts.Add(t);
                    }
                }
            }

            attachPointTestSprites.Clear();
            foreach (var v in obj.attachPointTestSprites)
            {
                if (v.spriteCollection != null && v.spriteCollection.IsValidSpriteId(v.spriteId))
                {
                    tk2dSpriteCollection.AttachPointTestSprite ap = new tk2dSpriteCollection.AttachPointTestSprite();
                    ap.CopyFrom(v);
                    attachPointTestSprites[v.attachPointName] = v;
                }
            }

            UpgradeLegacySpriteSheets();

            var target = this;
            var source = obj;

            target.platforms = new List <tk2dSpriteCollectionPlatform>();
            foreach (tk2dSpriteCollectionPlatform plat in source.platforms)
            {
                tk2dSpriteCollectionPlatform p = new tk2dSpriteCollectionPlatform();
                p.CopyFrom(plat);
                target.platforms.Add(p);
            }
            if (target.platforms.Count == 0)
            {
                tk2dSpriteCollectionPlatform plat = new tk2dSpriteCollectionPlatform();                 // add a null platform
                target.platforms.Add(plat);
            }
            target.enablePlatformScaleVertex = source.enablePlatformScaleVertex;

            target.assetName   = source.assetName;
            target.loadable    = source.loadable;
            target.atlasFormat = source.atlasFormat;

            target.maxTextureSize                 = source.maxTextureSize;
            target.forceTextureSize               = source.forceTextureSize;
            target.forcedTextureWidth             = source.forcedTextureWidth;
            target.forcedTextureHeight            = source.forcedTextureHeight;
            target.freeSizeAtlas                  = source.freeSizeAtlas;
            target.amountOfPixelsToExtendFreeSize = source.amountOfPixelsToExtendFreeSize;

            target.forceA8     = source.forceA8;
            target.forceShader = source.forceShader;

            target.textureCompression   = source.textureCompression;
            target.atlasWidth           = source.atlasWidth;
            target.atlasHeight          = source.atlasHeight;
            target.forceSquareAtlas     = source.forceSquareAtlas;
            target.atlasWastage         = source.atlasWastage;
            target.allowMultipleAtlases = source.allowMultipleAtlases;
            target.disableRotation      = source.disableRotation;
            target.removeDuplicates     = source.removeDuplicates;
            target.usePosterize         = source.usePosterize;
            target.posterizeValue       = source.posterizeValue;

            target.spriteCollection   = source.spriteCollection;
            target.premultipliedAlpha = source.premultipliedAlpha;

            CopyArray(ref target.altMaterials, source.altMaterials);
            CopyArray(ref target.atlasMaterials, source.atlasMaterials);
            CopyArray(ref target.atlasTextures, source.atlasTextures);
            CopyArray(ref target.atlasTextureFiles, source.atlasTextureFiles);
            CopyArray(ref target.atlasTexturePaths, source.atlasTexturePaths);

            CopyArray(ref target.atlasWidthTexture, source.atlasWidthTexture);
            CopyArray(ref target.atlasHeightTexture, source.atlasHeightTexture);

            target.sizeDef.CopyFrom(source.sizeDef);
            target.globalScale          = source.globalScale;
            target.globalTextureRescale = source.globalTextureRescale;
            target.physicsDepth         = source.physicsDepth;
            target.physicsEngine        = source.physicsEngine;
            target.disableTrimming      = source.disableTrimming;
            target.normalGenerationMode = source.normalGenerationMode;
            target.padAmount            = source.padAmount;
            target.innerPadAmount       = source.innerPadAmount;
            target.autoUpdate           = source.autoUpdate;
            target.editorDisplayScale   = source.editorDisplayScale;

            // Texture settings
            target.filterMode = source.filterMode;
            target.wrapMode   = source.wrapMode;
            target.userDefinedTextureSettings = source.userDefinedTextureSettings;
            target.mipmapEnabled    = source.mipmapEnabled;
            target.asyncLoadEnabled = source.asyncLoadEnabled;
            target.anisoLevel       = source.anisoLevel;
            target.forceA8          = source.forceA8;
        }
Пример #5
0
        public void CopyFromSource()
        {
            this.obj.Upgrade();             // make sure its up to date

            textureParams = new List <tk2dSpriteCollectionDefinition>(obj.textureParams.Length);
            foreach (var v in obj.textureParams)
            {
                if (v == null)
                {
                    textureParams.Add(null);
                }
                else
                {
                    var t = new tk2dSpriteCollectionDefinition();
                    t.CopyFrom(v);
                    textureParams.Add(t);
                }
            }

            spriteSheets = new List <tk2dSpriteSheetSource>();
            if (obj.spriteSheets != null)
            {
                foreach (var v in obj.spriteSheets)
                {
                    if (v == null)
                    {
                        spriteSheets.Add(null);
                    }
                    else
                    {
                        var t = new tk2dSpriteSheetSource();
                        t.CopyFrom(v);
                        spriteSheets.Add(t);
                    }
                }
            }

            fonts = new List <tk2dSpriteCollectionFont>();
            if (obj.fonts != null)
            {
                foreach (var v in obj.fonts)
                {
                    if (v == null)
                    {
                        fonts.Add(null);
                    }
                    else
                    {
                        var t = new tk2dSpriteCollectionFont();
                        t.CopyFrom(v);
                        fonts.Add(t);
                    }
                }
            }

            UpgradeLegacySpriteSheets();

            var target = this;
            var source = obj;

            target.platforms = new List <tk2dSpriteCollectionPlatform>();
            foreach (tk2dSpriteCollectionPlatform plat in source.platforms)
            {
                tk2dSpriteCollectionPlatform p = new tk2dSpriteCollectionPlatform();
                p.CopyFrom(plat);
                target.platforms.Add(p);
            }
            if (target.platforms.Count == 0)
            {
                tk2dSpriteCollectionPlatform plat = new tk2dSpriteCollectionPlatform();                 // add a null platform
                target.platforms.Add(plat);
            }

            target.assetName = source.assetName;
            target.loadable  = source.loadable;

            target.maxTextureSize      = source.maxTextureSize;
            target.forceTextureSize    = source.forceTextureSize;
            target.forcedTextureWidth  = source.forcedTextureWidth;
            target.forcedTextureHeight = source.forcedTextureHeight;

            target.textureCompression   = source.textureCompression;
            target.atlasWidth           = source.atlasWidth;
            target.atlasHeight          = source.atlasHeight;
            target.forceSquareAtlas     = source.forceSquareAtlas;
            target.atlasWastage         = source.atlasWastage;
            target.allowMultipleAtlases = source.allowMultipleAtlases;

            target.spriteCollection   = source.spriteCollection;
            target.premultipliedAlpha = source.premultipliedAlpha;

            CopyArray(ref target.altMaterials, source.altMaterials);
            CopyArray(ref target.atlasMaterials, source.atlasMaterials);
            CopyArray(ref target.atlasTextures, source.atlasTextures);

            target.useTk2dCamera        = source.useTk2dCamera;
            target.targetHeight         = source.targetHeight;
            target.targetOrthoSize      = source.targetOrthoSize;
            target.globalScale          = source.globalScale;
            target.physicsDepth         = source.physicsDepth;
            target.disableTrimming      = source.disableTrimming;
            target.normalGenerationMode = source.normalGenerationMode;
            target.padAmount            = source.padAmount;
            target.autoUpdate           = source.autoUpdate;
            target.editorDisplayScale   = source.editorDisplayScale;

            // Texture settings
            target.filterMode = source.filterMode;
            target.wrapMode   = source.wrapMode;
            target.userDefinedTextureSettings = source.userDefinedTextureSettings;
            target.mipmapEnabled = source.mipmapEnabled;
            target.anisoLevel    = source.anisoLevel;
        }