Пример #1
0
        public static void AutoImport(string input, string output)
        {
            PfiDocument doc = Import(input);

            if (!Directory.Exists(output))
            {
                Directory.CreateDirectory(output);
            }

            if (doc != null && doc.root.layers.Count > 0)
            {
                PfiLayer layer;

                for (int i = 0; i < doc.root.layers.Count; i++)
                {
                    layer = doc.root.layers[i];

                    if (layer != null)
                    {
                        string path   = string.Format("{0}/{1}.png", output, layer.name);
                        byte[] buffer = layer.texture.EncodeToPNG();
                        if (File.Exists(path))
                        {
                            File.Delete(path);
                        }
                        File.WriteAllBytes(path, buffer);
                    }
                }
            }
            ImportAsset(output, doc);
        }
Пример #2
0
        private static PfiDocument ProcessDocument(PsdDocument psd)
        {
            var doc = new PfiDocument();

            doc.size = new Vector2(psd.Width, psd.Height);
            doc.root = new PfiFolder("");
            ProcessChildren(psd, doc.root, psd);
            return(doc);
        }
Пример #3
0
 private static void ImportAsset(string path, PfiDocument doc, string assetName = "psd")
 {
     path = path.Replace(Application.dataPath, "Assets");
 }