almost worked out the generic json importer

This commit is contained in:
Dylan Wilson
2019-06-25 23:20:58 +10:00
parent cb159e15b0
commit 438836078d
19 changed files with 384 additions and 232 deletions
+221 -221
View File
@@ -31,12 +31,7 @@
/processor:TexturePackerProcessor
/build:adventure-gui-atlas.json
#begin small-font.fnt
/importer:BitmapFontImporter
/processor:BitmapFontProcessor
/build:small-font.fnt
#begin small-font_0.png
#begin Animations/fireball.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
@@ -46,7 +41,41 @@
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:small-font_0.png
/build:Animations/fireball.png
#begin Animations/motw.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Animations/motw.png
#begin Animations/zombie.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Animations/zombie.png
#begin Animations/zombie-animations.aa
/importer:AstridAnimatorImporter
/processor:AstridAnimatorProcessor
/build:Animations/zombie-animations.aa
#begin Animations/zombie-atlas.json
/importer:JsonContentImporter
/processor:JsonContentProcessor
/build:Animations/zombie-atlas.json
#begin Fonts/impact-32.fnt
/importer:BitmapFontImporter
@@ -82,19 +111,12 @@
/processorParam:TextureFormat=Color
/build:Fonts/montserrat-32_0.png
#begin Textures/logo-square-512.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/logo-square-512.png
#begin small-font.fnt
/importer:BitmapFontImporter
/processor:BitmapFontProcessor
/build:small-font.fnt
#begin Textures/vignette.png
#begin small-font_0.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
@@ -104,175 +126,7 @@
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/vignette.png
#begin Textures/hills.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills.png
#begin Textures/hills-sky.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills-sky.png
#begin Textures/hills-clouds.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills-clouds.png
#begin Textures/hills-4.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills-4.png
#begin Textures/hills-3.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills-3.png
#begin Textures/hills-2.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills-2.png
#begin Textures/hills-1.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills-1.png
#begin Textures/logo-square-128.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/logo-square-128.png
#begin Textures/car-wheel.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/car-wheel.png
#begin Textures/car-hull.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/car-hull.png
#begin Textures/spike_ball.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/spike_ball.png
#begin Textures/particle.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/particle.png
#begin Textures/clipping-test.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/clipping-test.png
#begin Textures/bg_sharbi.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/bg_sharbi.png
/build:small-font_0.png
#begin Textures/axe.png
/importer:TextureImporter
@@ -286,7 +140,7 @@
/processorParam:TextureFormat=Color
/build:Textures/axe.png
#begin Animations/fireball.png
#begin Textures/bg_sharbi.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
@@ -296,9 +150,9 @@
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Animations/fireball.png
/build:Textures/bg_sharbi.png
#begin Animations/motw.png
#begin Textures/car-hull.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
@@ -308,19 +162,9 @@
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Animations/motw.png
/build:Textures/car-hull.png
#begin Animations/zombie-animations.aa
/importer:AstridAnimatorImporter
/processor:AstridAnimatorProcessor
/build:Animations/zombie-animations.aa
#begin Animations/zombie-atlas.json
/importer:TexturePackerJsonImporter
/processor:TexturePackerProcessor
/build:Animations/zombie-atlas.json
#begin Animations/zombie.png
#begin Textures/car-wheel.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
@@ -330,7 +174,175 @@
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Animations/zombie.png
/build:Textures/car-wheel.png
#begin Textures/clipping-test.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/clipping-test.png
#begin Textures/colored_castle.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/colored_castle.png
#begin Textures/hills.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills.png
#begin Textures/hills-1.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills-1.png
#begin Textures/hills-2.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills-2.png
#begin Textures/hills-3.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills-3.png
#begin Textures/hills-4.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills-4.png
#begin Textures/hills-clouds.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills-clouds.png
#begin Textures/hills-sky.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills-sky.png
#begin Textures/logo-square-128.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/logo-square-128.png
#begin Textures/logo-square-512.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/logo-square-512.png
#begin Textures/particle.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/particle.png
#begin Textures/spike_ball.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/spike_ball.png
#begin Textures/vignette.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/vignette.png
#begin TiledMaps/abstractTiles_sheet.png
/importer:TextureImporter
@@ -444,6 +456,11 @@
/processor:TiledMapProcessor
/build:TiledMaps/level07.tmx
#begin TiledMaps/level08.tmx
/importer:TiledMapImporter
/processor:TiledMapProcessor
/build:TiledMaps/level08.tmx
#begin TiledMaps/non-uniform-tileset.png
/importer:TextureImporter
/processor:TextureProcessor
@@ -492,20 +509,3 @@
/processorParam:TextureFormat=Color
/build:TiledMaps/voxelTiles_sheet.png
#begin TiledMaps/level08.tmx
/importer:TiledMapImporter
/processor:TiledMapProcessor
/build:TiledMaps/level08.tmx
#begin Textures/colored_castle.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/colored_castle.png
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
<Asset Type="GeonBit.UI.DataTypes.TextureData">
<FrameWidth>0.28</FrameWidth>
<FrameHeight>0.0</FrameHeight>
</Asset>
</XnaContent>
@@ -217,7 +217,7 @@ namespace Features.Demos
public void Draw(SpriteBatch spriteBatch)
{
//spriteBatch.Draw(_sprite);
spriteBatch.Draw(_sprite, _transform);
}
public void Walk(float direction)
@@ -9,7 +9,8 @@ namespace MonoGame.Extended.Animations.SpriteSheets
{
protected override SpriteSheetAnimationFactory Read(ContentReader reader, SpriteSheetAnimationFactory existingInstance)
{
var textureAtlasAssetName = reader.GetRelativeAssetName(reader.ReadString());
var relativeName = reader.ReadString();
var textureAtlasAssetName = reader.GetRelativeAssetName(relativeName);
var textureAtlas = reader.ContentManager.Load<TextureAtlas>(textureAtlasAssetName);
var frameCount = reader.ReadInt32();
var regions = new List<TextureRegion2D>();
@@ -0,0 +1,15 @@
using System.IO;
using Microsoft.Xna.Framework.Content.Pipeline;
namespace MonoGame.Extended.Content.Pipeline.Json
{
[ContentImporter(".json", DefaultProcessor = nameof(JsonContentProcessor), DisplayName = "JSON Importer - MonoGame.Extended")]
public class JsonContentImporter : ContentImporter<ContentImporterResult<string>>
{
public override ContentImporterResult<string> Import(string filename, ContentImporterContext context)
{
var json = File.ReadAllText(filename);
return new ContentImporterResult<string>(filename, json);
}
}
}
@@ -0,0 +1,23 @@
using System;
using Microsoft.Xna.Framework.Content.Pipeline;
namespace MonoGame.Extended.Content.Pipeline.Json
{
[ContentProcessor(DisplayName = "JSON Processor - MonoGame.Extended")]
public class JsonContentProcessor : ContentProcessor<ContentImporterResult<string>, JsonContentProcessorResult>
{
public override JsonContentProcessorResult Process(ContentImporterResult<string> input, ContentProcessorContext context)
{
try
{
var output = new JsonContentProcessorResult { Json = input.Data };
return output;
}
catch (Exception ex)
{
context.Logger.LogMessage("Error {0}", ex);
throw;
}
}
}
}
@@ -0,0 +1,7 @@
namespace MonoGame.Extended.Content.Pipeline.Json
{
public class JsonContentProcessorResult
{
public string Json { get; set; }
}
}
@@ -0,0 +1,29 @@
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
using MonoGame.Extended.Sprites;
namespace MonoGame.Extended.Content.Pipeline.Json
{
[ContentTypeWriter]
public class JsonContentTypeWriter : ContentTypeWriter<JsonContentProcessorResult>
{
protected override void Write(ContentWriter writer, JsonContentProcessorResult result)
{
writer.Write(result.Json);
}
public override string GetRuntimeReader(TargetPlatform targetPlatform)
{
return "MonoGame.Extended.Serialization.JsonContentTypeReader, MonoGame.Extended";
}
public override string GetRuntimeType(TargetPlatform targetPlatform)
{
var type = typeof(Sprite);
var readerType = type.Namespace + ".JsonContentTypeReader, " + type.AssemblyQualifiedName;
return "GetRuntimeType";
//return typeof(object).AssemblyQualifiedName;// "MonoGame.Extended.Serialization.JsonContentTypeReader, MonoGame.Extended";
}
}
}
@@ -1,5 +1,6 @@
using System.IO;
using Microsoft.Xna.Framework.Content.Pipeline;
using MonoGame.Extended.TextureAtlases;
using Newtonsoft.Json;
namespace MonoGame.Extended.Content.Pipeline.TextureAtlases
@@ -1,5 +1,6 @@
using System;
using Microsoft.Xna.Framework.Content.Pipeline;
using MonoGame.Extended.TextureAtlases;
namespace MonoGame.Extended.Content.Pipeline.TextureAtlases
{
@@ -1,4 +1,6 @@
namespace MonoGame.Extended.Content.Pipeline.TextureAtlases
using MonoGame.Extended.TextureAtlases;
namespace MonoGame.Extended.Content.Pipeline.TextureAtlases
{
public class TexturePackerProcessorResult
{
@@ -15,10 +15,15 @@ namespace MonoGame.Extended.Content
return (GraphicsDevice)_contentReaderGraphicsDeviceFieldInfo.GetValue(contentReader);
}
public static string RemoveExtension(string path)
{
return Path.ChangeExtension(path, null).TrimEnd('.');
}
public static string GetRelativeAssetName(this ContentReader contentReader, string relativeName)
{
var assetDirectory = Path.GetDirectoryName(contentReader.AssetName);
var assetName = Path.Combine(assetDirectory, relativeName).Replace('\\', '/');
var assetName = RemoveExtension(Path.Combine(assetDirectory, relativeName).Replace('\\', '/'));
return ShortenRelativePath(assetName);
}
@@ -0,0 +1,59 @@
using System;
using System.IO;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using MonoGame.Extended.Content;
using MonoGame.Extended.TextureAtlases;
using Newtonsoft.Json;
namespace MonoGame.Extended.Serialization
{
public class JsonContentTypeReader : ContentTypeReader
{
//protected override object Read(ContentReader input, object existingInstance)
//{
// var json = input.ReadString();
// return null;
//}
public JsonContentTypeReader() : base(typeof(TextureAtlas))
{
}
protected override object Read(ContentReader reader, object existingInstance)
{
var json = reader.ReadString();
using (var stringReader = new StringReader(json))
using (var jsonReader = new JsonTextReader(stringReader))
{
var serializer = new JsonSerializer();
var texturePackerFile = serializer.Deserialize<TexturePackerFile>(jsonReader);
var assetName = reader.GetRelativeAssetName(texturePackerFile.Metadata.Image);
var texture = reader.ContentManager.Load<Texture2D>(assetName);
var atlas = new TextureAtlas(assetName, texture);
var regionCount = texturePackerFile.Regions.Count;
for (var i = 0; i < regionCount; i++)
{
atlas.CreateRegion(
ContentReaderExtensions.RemoveExtension(texturePackerFile.Regions[i].Filename),
texturePackerFile.Regions[i].Frame.X,
texturePackerFile.Regions[i].Frame.Y,
texturePackerFile.Regions[i].Frame.Width,
texturePackerFile.Regions[i].Frame.Height);
}
return atlas;
return texturePackerFile;
}
}
}
}
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using Newtonsoft.Json;
namespace MonoGame.Extended.Content.Pipeline.TextureAtlases
namespace MonoGame.Extended.TextureAtlases
{
public class TexturePackerFile
{
@@ -1,6 +1,6 @@
using Newtonsoft.Json;
namespace MonoGame.Extended.Content.Pipeline.TextureAtlases
namespace MonoGame.Extended.TextureAtlases
{
public class TexturePackerMeta
{
@@ -1,6 +1,6 @@
using Newtonsoft.Json;
namespace MonoGame.Extended.Content.Pipeline.TextureAtlases
namespace MonoGame.Extended.TextureAtlases
{
public class TexturePackerPoint
{
@@ -1,6 +1,6 @@
using Newtonsoft.Json;
namespace MonoGame.Extended.Content.Pipeline.TextureAtlases
namespace MonoGame.Extended.TextureAtlases
{
public class TexturePackerRectangle
{
@@ -1,6 +1,6 @@
using Newtonsoft.Json;
namespace MonoGame.Extended.Content.Pipeline.TextureAtlases
namespace MonoGame.Extended.TextureAtlases
{
public class TexturePackerRegion
{
@@ -27,7 +27,7 @@ namespace MonoGame.Extended.Content.Pipeline.TextureAtlases
public override string ToString()
{
return string.Format("{0} {1}", Filename, Frame);
return $"{Filename} {Frame}";
}
}
}
@@ -1,6 +1,6 @@
using Newtonsoft.Json;
namespace MonoGame.Extended.Content.Pipeline.TextureAtlases
namespace MonoGame.Extended.TextureAtlases
{
public class TexturePackerSize
{