예제 #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");
 }