Ejemplo n.º 1
0
        private void DefaultImport(AssetImportContext ctx)
        {
            // import as simple texture
            var merged   = _fileData.GetMergedLayers();
            var textName = _fileData.GetTextureName(merged);

            ctx.AddObjectToAsset(textName, merged);
            ctx.SetMainObject(merged);
        }
Ejemplo n.º 2
0
        /// <summary> add layers as atlas </summary>
        private Texture2D CreateAtlas(
            MultiLayerImageFileData multiLayerImageFileData, out List <Sprite> sprites)
        {
            var textures     = multiLayerImageFileData.GetLayers();
            var atlasTexture = CrateAtlasTexture(textures, out var rects);
            var fileName     = multiLayerImageFileData.GetFileName();


            sprites = new List <Sprite>();

            for (var i = 0; i < rects.Length; i++)
            {
                var rect   = rects[i];
                var sprite = CreateAtlasSprite(atlasTexture, rect);
                // sprites
                sprite.name = multiLayerImageFileData.GetTextureName(textures[i]);
                sprites.Add(sprite);
            }

            atlasTexture.name = fileName;
            return(atlasTexture);
        }