Skip to content

Instantly share code, notes, and snippets.

@harry-cpp
Last active November 18, 2019 21:48
Show Gist options
  • Save harry-cpp/76f62c79d96dec9de13f3923fc329784 to your computer and use it in GitHub Desktop.
Save harry-cpp/76f62c79d96dec9de13f3923fc329784 to your computer and use it in GitHub Desktop.
New content builder prototype code
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Processors;
namespace Pong.Content
{
public class Main : IContentProject
{
public void Run(Builder builder)
{
// You can use regex instead of wildcards if you want for selecting files
// builder.UseRegex = true;
// Include all .png files with whatever is the default importer / processor
builder.Include("Textures/*.png");
// Include tilemap.png with specific importer/processor and settings
// this will override the above include for any file that passed the wildcard
builder.Include(
"tilemap.png",
new TextureImporter(),
new TextureProcessor()
{
ColorKeyColor = new Color(1.0f, 0.5f, 0.5f)
}
);
// Exclude the test.png file
builder.Exclude("Textures/test.png");
// Include a custom file for a platform
// and also change its output path
if (builder.Platform == TargetPlatform.Android)
{
builder.Include("touchscreen-android.png", "touchscreen.xnb");
}
else
{
builder.Include("touchscreen-other.png", "touchscreen.xnb");
}
// Include files and dynamically change their output names
builder.Include("Platform/*.png", (filePath) => filePath.Replace("replace_me", "something").Replace(".png", ".xnb"));
// Build the content
builder.Build();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment