public void CreateMaterials(SpriteStudioCellMap cellMap)
        {
            string destFileName = texturesDirectory + "/" + cellMap.imagePath;
            string fileName = Path.GetFileNameWithoutExtension (cellMap.imagePath);
            Texture2D texture = AssetDatabase.LoadAssetAtPath (destFileName, typeof(Texture2D)) as Texture2D;

            Material addMaterial = new Material (Shader.Find ("Custom/SpriteStudio5/Add"));
            addMaterial.mainTexture = texture;
            AssetDatabase.CreateAsset (addMaterial, materialsDirectory + "/" + fileName + "_Add.mat");
            addMaterialDict [cellMap.name] = addMaterial;

            Material mixMaterial = new Material (Shader.Find ("Custom/SpriteStudio5/Mix"));
            mixMaterial.mainTexture = texture;
            AssetDatabase.CreateAsset (mixMaterial, materialsDirectory + "/" + fileName + "_Mix.mat");
            mixMaterialDict [cellMap.name] = mixMaterial;

            Material mulMaterial = new Material (Shader.Find ("Custom/SpriteStudio5/Mul"));
            mulMaterial.mainTexture = texture;
            AssetDatabase.CreateAsset (mulMaterial, materialsDirectory + "/" + fileName + "_Mul.mat");
            mulMaterialDict [cellMap.name] = mulMaterial;

            Material subMaterial = new Material (Shader.Find ("Custom/SpriteStudio5/Sub"));
            subMaterial.mainTexture = texture;
            AssetDatabase.CreateAsset (subMaterial, materialsDirectory + "/" + fileName + "_Sub.mat");
            subMaterialDict [cellMap.name] = subMaterial;

            AssetDatabase.SaveAssets ();
            AssetDatabase.Refresh ();
        }
        public void CreateTexture(SpriteStudioCellMap cellMap)
        {
            string destFileName = texturesDirectory + "/" + cellMap.imagePath;
            File.Copy (sourceDirectory + "/" + cellMap.imagePath, destFileName, true);
            AssetDatabase.ImportAsset (destFileName);
            TextureImporter importer = TextureImporter.GetAtPath (destFileName) as TextureImporter;
            if (importer != null) {
                importer.textureType = TextureImporterType.Advanced;
                importer.maxTextureSize = 4096;
                importer.textureFormat = TextureImporterFormat.AutomaticTruecolor;
                importer.isReadable = false;
                importer.filterMode = FilterMode.Bilinear;
                importer.npotScale = TextureImporterNPOTScale.None;
                importer.wrapMode = TextureWrapMode.Clamp;
                importer.mipmapEnabled = false;
                importer.spriteImportMode = SpriteImportMode.Multiple;
                importer.spritePixelsPerUnit = 1;

                List<SpriteMetaData> spritesheet = new List<SpriteMetaData> ();
                Vector2 pixelSize = GetVector2 (cellMap.pixelSize);
                foreach (SpriteStudioCellMapCell cell in cellMap.cells) {
                    SpriteMetaData metaData = new SpriteMetaData ();
                    metaData.alignment = (int)SpriteAlignment.Custom;
                    metaData.name = cell.name;
                    Vector2 size = GetVector2 (cell.size);
                    Vector2 pos = GetVector2 (cell.pos);
                    Vector2 pivot = GetVector2 (cell.pivot);
                    metaData.rect = new Rect (pos.x, pixelSize.y - pos.y - size.y, size.x, size.y);
                    metaData.pivot = new Vector2 (pivot.x + 0.5f, pivot.y + 0.5f);
                    spritesheet.Add (metaData);
                }
                importer.spritesheet = spritesheet.ToArray ();
                AssetDatabase.ImportAsset (destFileName);
                AssetDatabase.SaveAssets ();
                AssetDatabase.Refresh ();
            }
        }
        public void CreateCellData(SpriteStudioCellMap cellMap, int mapId)
        {
            List<SSCell> cellList = new List<SSCell> ();
            string guid = AssetDatabase.CreateFolder (cellDataDirectory, cellMap.name);
            string subDirectory = AssetDatabase.GUIDToAssetPath (guid);
            foreach (SpriteStudioCellMapCell cell in cellMap.cells) {
                SSCell c = ScriptableObject.CreateInstance<SSCell> ();
                c.mapId = mapId;
                c.mixMaterial = mixMaterialDict [cellMap.name];
                c.addMaterial = addMaterialDict [cellMap.name];
                c.mulMaterial = mulMaterialDict [cellMap.name];
                c.subMaterial = subMaterialDict [cellMap.name];
                c.size = GetVector2 (cell.size);
                c.pos = GetVector2 (cell.pos);
                c.pivot = GetVector2 (cell.pivot);
                c.pixelSize = GetVector2 (cellMap.pixelSize);
                c.Calculate ();

                cellList.Add (c);
                AssetDatabase.CreateAsset (c, subDirectory + "/" + cell.name + ".asset");
                AssetDatabase.SaveAssets ();
                AssetDatabase.Refresh ();
            }

            cellMaps [cellMap.cellmapName] = cellList;
        }