public override Dictionary <string, Rect> ParseData(string name, string data) { if (!DataDict.ContainsKey(name)) { DataDict.Add(name, new Dictionary <string, Rect>()); JsonReader reader = new JsonReader(); UnityJsonData jsonData = reader.Read <UnityJsonData>(data); DualSize texSize = jsonData.meta.size; foreach (KeyValuePair <string, Frame> item in jsonData.frames) { string frameName = item.Key; Frame frameData = item.Value; // Calculate Vector2 scale = new Vector2(frameData.frame.w / texSize.w, frameData.frame.h / texSize.h); Vector2 offset = new Vector2(frameData.frame.x / texSize.w, (texSize.h - frameData.frame.y - frameData.sourceSize.h) / texSize.h); Rect rect = new Rect(offset.x, offset.y, scale.x, scale.y); DataDict[name].Add(frameName, rect); } } return(DataDict[name]); }
public Frame(string name, QuatSize frame, bool rotated, bool trimmed, QuatSize spriteSourceSize, DualSize sourceSize) { this.name = name; this.frame = frame; this.rotated = rotated; this.trimmed = trimmed; this.spriteSourceSize = spriteSourceSize; this.sourceSize = sourceSize; }
public Meta(string app, string version, string image, string format, DualSize size, string scale, string smartupdate) { this.app = app; this.version = version; this.image = image; this.format = format; this.size = size; this.scale = scale; this.smartupdate = smartupdate; }