public override void OnImportAsset(UnityEditor.AssetImporters.AssetImportContext ctx) { var serializer = new DataContractJsonSerializer(typeof(PiskelFile)); var layerSerializer = new DataContractJsonSerializer(typeof(PiskelLayer)); using (var assetFile = File.OpenRead(ctx.assetPath)) { var piskelFile = (PiskelFile)serializer.ReadObject(assetFile); var frameWidth = piskelFile.piskel.width; var frameHeight = piskelFile.piskel.height; if (piskelFile.modelVersion != 2) { ctx.LogImportWarning("expected piskel model version 2"); } var layers = piskelFile.piskel.layers .Select(layerJson => { using (var textReader = new MemoryStream(Encoding.Unicode.GetBytes(layerJson))) { return(layerSerializer.ReadObject(textReader)); } }) .Cast <PiskelLayer>() .ToList(); var layerTextures = layers .Select((layer, l) => { if (layer.chunks.Length != 1) { ctx.LogImportWarning("not supported: piskel layer with no chunks, or more than one chunk:" + layer.name); return(default);