Exemplo n.º 1
0
 private static void MapRepository(TextureImporterWrapper textureImporterWrapper)
 {
     for (int index = 0; index < _rawContainer.frames.Length; index++)
     {
         var frame  = _rawContainer.frames[index];
         var folder = GenerateFolder(frame);
         CreateOrUpdateSprite(folder, frame, textureImporterWrapper);
     }
 }
Exemplo n.º 2
0
        private static void CreateOrUpdateSprite(Folder folder, Frame frame, TextureImporterWrapper textureImporterWrapper)
        {
            var spriteDescription = GetSpriteDescription(folder, frame.filename);

            if (spriteDescription == null)
            {
                spriteDescription = CreateSpriteDescription(folder, frame, textureImporterWrapper);
                _newSpriteDescriptions.Add(spriteDescription);
            }
            TransformationModificators.Modificate(spriteDescription);
            CreateSpriteMetaData(frame, textureImporterWrapper, spriteDescription);
        }
Exemplo n.º 3
0
        private static void SetSprites()
        {
            _outputlog.AppendLine();
            _outputlog.AppendLine("*** New sprites ***");
            _outputlog.AppendLine();

            using (var textureImporterWrapper = new TextureImporterWrapper(_textureAssetPath, false))
            {
                foreach (var spriteDescription in _newSpriteDescriptions)
                {
                    spriteDescription.Sprite = textureImporterWrapper.GetSprite(spriteDescription.FileName);
                    _outputlog.AppendLine(spriteDescription.FileName);
                }
            }
        }
Exemplo n.º 4
0
 public static string Transform(TextureDescription textureDescription, TextureRepository textureRepository)
 {
     _outputlog             = new StringBuilder();
     _textureRepository     = textureRepository;
     _textureDescription    = textureDescription;
     _textureAssetPath      = AssetDatabase.GetAssetPath(_textureDescription.Texture);
     _rawContainer          = Domain.Domain.LoadContainer(_textureDescription.JsonDataFile);
     _newSpriteDescriptions = new List <SpriteDescription>();
     using (var textureImporterWrapper = new TextureImporterWrapper(_textureAssetPath))
     {
         textureImporterWrapper.ClearSpritesMetaData();
         MapRepository(textureImporterWrapper);
     }
     EditorUtility.SetDirty(_textureDescription);
     SetSprites();
     return(_outputlog.ToString());
 }
Exemplo n.º 5
0
        private static SpriteDescription CreateSpriteDescription(Folder folder, Frame frame, TextureImporterWrapper textureImporterWrapper)
        {
            _outputlog.Append(' ', folder.Depth * 3);
            _outputlog.AppendLine(string.Format("- Sprite Description created: {0}", frame.filename));
            var spriteDesription = new SpriteDescription()
            {
                FileName = frame.filename, Pivot = new Vector2(frame.pivot.x, frame.pivot.y),
            };

            folder.SpriteDescriptions.Add(spriteDesription);
            return(spriteDesription);
        }
Exemplo n.º 6
0
        private static void CreateSpriteMetaData(Frame frame, TextureImporterWrapper textureImporterWrapper, SpriteDescription spriteDescription)
        {
            var rect = new Rect(frame.frame.x, _textureDescription.Texture.height - frame.frame.y - frame.frame.h, frame.frame.w, frame.frame.h);

            textureImporterWrapper.AddSpriteMetaData(frame.filename, rect, spriteDescription.Pivot, spriteDescription.Borders);
        }