Files
MonoGame.Extended/Source/MonoGame.Extended.Content.Pipeline/TextureAtlases/TexturePackerJsonImporter.cs
T
2017-01-31 21:15:21 +10:00

23 lines
860 B
C#

using System.IO;
using Microsoft.Xna.Framework.Content.Pipeline;
using Newtonsoft.Json;
namespace MonoGame.Extended.Content.Pipeline.TextureAtlases
{
[ContentImporter(".json", DefaultProcessor = "TexturePackerProcessor",
DisplayName = "TexturePacker JSON Importer - MonoGame.Extended")]
public class TexturePackerJsonImporter : ContentImporter<TexturePackerFile>
{
public override TexturePackerFile Import(string filename, ContentImporterContext context)
{
using (var streamReader = new StreamReader(filename))
{
using (var jsonReader = new JsonTextReader(streamReader))
{
var serializer = new JsonSerializer();
return serializer.Deserialize<TexturePackerFile>(jsonReader);
}
}
}
}
}