public override void OnImport()
        {
            size = new Vector2Int(AsepriteFile.Header.Width, AsepriteFile.Header.Height);

            frames = AsepriteFile.GetFrames();
            BuildAtlas(AssetPath);
        }
Exemplo n.º 2
0
        public override void OnImport()
        {
            size = new Vector2Int(AsepriteFile.Header.Width, AsepriteFile.Header.Height);

            Texture2D frame = AsepriteFile.GetFrames()[0];

            BuildAtlas(AssetPath, frame);
        }
Exemplo n.º 3
0
        public void GenerateAtlasTexture(bool overwriteSprites = false)
        {
            if (atlas != null)
            {
                return;
            }

            SpriteAtlasBuilder atlasBuilder = new SpriteAtlasBuilder(AsepriteFile.Header.Width, AsepriteFile.Header.Height);

            Texture2D[] frames = AsepriteFile.GetFrames();

            atlas = atlasBuilder.GenerateAtlas(frames, out AseFileSpriteImportData[] importData);

            textureWidth  = atlas.width;
            textureHeight = atlas.height;
            frameCount    = importData.Length;

            // Rename sprites

            if (overwriteSprites)
            {
                for (int i = 0; i < importData.Length; i++)
                {
                    importData[i].name = string.Format("{0}_{1}", name, importData[i].name);
                }

                SpriteRects      = new SpriteRect[0];
                SpriteImportData = importData;

                if (SpriteImportData.Length > 1)
                {
                    TextureImportSettings.spriteMode = (int)SpriteImportMode.Multiple;
                }


                AssetDatabase.WriteImportSettingsIfDirty(AssetPath);
            }
        }