SpriteStudioForUnity.SpriteStudioBaker.CreateCellData C# (CSharp) Méthode

CreateCellData() public méthode

public CreateCellData ( SpriteStudioCellMap cellMap, int mapId ) : void
cellMap SpriteStudioCellMap
mapId int
Résultat void
        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;
        }

Usage Example

        bool CreateCellDatas(SpriteStudioBaker baker)
        {
            baker.cellMaps = new Dictionary<string, List<SSCell>>();

            if (baker.cellMapList == null)
                return true;

            int mapId = 0;

            string message = null;
            try
            {
                for (int i = 0; i < baker.cellMapList.Count; i++)
                {
                    SpriteStudioCellMap cellMap = baker.cellMapList [i];
                    message = cellMap.name;
                    EditorUtility.DisplayProgressBar("Sprite Studio For Unity", "Create CellData(" + (i + 1) + "/" + baker.cellMapList.Count + ") : " + cellMap.name, 0.7f);
                    baker.CreateCellData(cellMap, mapId);
                    mapId++;
                }
            } catch (Exception e)
            {
                EditorUtility.DisplayDialog("Error", "Create CellData : " + message, "OK");
                Debug.Log(e.StackTrace);
                return false;
            }
            return true;
        }