private static void ParseLayers(JsonReader reader, LottieComposition composition, List <Layer> layers, Dictionary <long, Layer> layerMap) { var imageCount = 0; reader.BeginArray(); while (reader.HasNext()) { var layer = LayerParser.Parse(reader, composition); if (layer.GetLayerType() == Layer.LayerType.Image) { imageCount++; } layers.Add(layer); layerMap[layer.Id] = layer; if (imageCount > 4) { LottieLog.Warn($"You have {imageCount} images. Lottie should primarily be used with shapes. If you are using Adobe Illustrator, convert the Illustrator layers to shape layers."); } } reader.EndArray(); }
private static void ParseAssets(JsonReader reader, LottieComposition composition, Dictionary <string, List <Layer> > precomps, Dictionary <string, LottieImageAsset> images) { reader.BeginArray(); while (reader.HasNext()) { string id = null; // For precomps var layers = new List <Layer>(); var layerMap = new Dictionary <long, Layer>(); // For images var width = 0; var height = 0; string imageFileName = null; string relativeFolder = null; reader.BeginObject(); while (reader.HasNext()) { switch (reader.NextName()) { case "id": id = reader.NextString(); break; case "layers": reader.BeginArray(); while (reader.HasNext()) { var layer = LayerParser.Parse(reader, composition); layerMap.Add(layer.Id, layer); layers.Add(layer); } reader.EndArray(); break; case "w": width = reader.NextInt(); break; case "h": height = reader.NextInt(); break; case "p": imageFileName = reader.NextString(); break; case "u": relativeFolder = reader.NextString(); break; default: reader.SkipValue(); break; } } reader.EndObject(); if (imageFileName != null) { var image = new LottieImageAsset(width, height, id, imageFileName, relativeFolder); images[image.Id] = image; } else { precomps.Add(id, layers); } } reader.EndArray(); }