Example #1
0
        private IEnumerator LoadAtlases(EditorImporter importer, Sein_atlasExtension extension)
        {
            var atlases  = extension.atlases;
            var basePath = Path.Combine(importer.importDirectoryPath, "atlases");

            Directory.CreateDirectory(basePath);
            IMPORTED_ATLASES = new SeinAtlas[atlases.Count];
            int i = 0;

            foreach (var atlas in atlases)
            {
                LoadAtlas(atlas, importer, basePath, i);
                importer.SetProgress("ATLAS", (i + 1), atlases.Count);
                i += 1;

                yield return(null);
            }
        }
Example #2
0
        public override void Serialize(ExporterEntry entry, Dictionary <string, Extension> extensions, UnityEngine.Object component = null, object options = null)
        {
            if (!ENTRY_ATLASES.ContainsKey(entry))
            {
                ENTRY_ATLASES.Add(entry, new List <SeinAtlas>());
            }

            Sein_atlasExtension extension;
            var atlas = component as SeinAtlas;

            if (!extensions.ContainsKey(ExtensionName))
            {
                extension = new Sein_atlasExtension();
                AddExtension(extensions, extension);
            }
            else
            {
                extension = (Sein_atlasExtension)extensions[ExtensionName];
            }

            var list = ENTRY_ATLASES[entry];

            if (list.Contains(atlas))
            {
                return;
            }

            var tex = AssetDatabase.LoadAssetAtPath <Texture2D>(atlas.atlasPath);

            if (tex == null)
            {
                Utils.ThrowExcption("Atlas '" + atlas.name + "' is not saved!");
            }
            var imageId = entry.SaveImage(tex, true, null, maxSize: Math.Max(tex.width, tex.height), flipY: false);
            var json    = atlas.ReadJson();

            json["meta"]["image"] = new JObject(new JProperty("index", imageId.Id));

            extension.atlases.Add(new Sein_atlasExtension.Atlas {
                json = json
            });
            list.Add(atlas);
        }