Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7065015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:54:18+00:00 2026-05-28T04:54:18+00:00

I have tried to get my head around the content processor and textures, but

  • 0

I have tried to get my head around the content processor and textures, but I am a bit confused… I have 2 scenarios:

  • One is a model that contains a texture, the importer loads the xml and passes the texture filename to the processor, but I can only get a TextureContent, which seems to be a compile time reference to a texture, but this doesn’t help me populate the Texture2D bit of my model.

  • The 2nd scenario is I want to piggyback of the texture processor to create a spritemap object from a texture file, the spritemap is basically a model which contains a texture and sprite width/height.

The thing that keeps getting me stumped is these ExternalReference and TextureContent, as the model, lets say:

public class SpriteMap
{
    public Texture2D Texture { get; private set; }
    public int SpriteWidth { get; private set; }
    public int SpriteHeight { get; private set; }

    public SpriteMap(Texture2D texture, int spriteWidth, int spriteHeight)
    {
        this.texture = texture;
        this.spriteWidth = spriteWidth;
        this.spriteHeight = spriteHeight;
    }
}

Then I have a content processor like so:

[ContentProcessor(DisplayName = "TextureToSpriteMapProcessor")]
public class TextureToSpriteMapProcessor : ContentProcessor<Texture2D, ISpriteMap>
{
    [DisplayName("Sprite Width")]
    [DefaultValue(64)]
    [Description("The size of each sprite's width within the sprite map.")]
    public virtual int SpriteWidth { get; set; }

    [DisplayName("Sprite Height")]
    [DefaultValue(64)]
    [Description("The size of each sprite's height within the sprite map.")]
    public virtual int SpriteHeight { get; set; }

    public override ISpriteMap Process(Texture2D input, ContentProcessorContext context)
    { return new SpriteMap(input, SpriteWidth, SpriteHeight); }
}

Now it complains that the processor is given a TextureContent, but that isn’t a texture… but for some reason a TextureContent seems to magically turn into a Texture when it is loaded via the contentManager… so I am a bit baffled as to how I can get a texture in this instance. As both scenarios are fairly similar I am sure if I solve one I will solve them both, but ideally I want to be able to go:

contentManager.Load<ISpriteMap>("someTextureAsset");

If anyone can explain how to make this seemingly magic process work, I will give you much praise!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:54:18+00:00Added an answer on May 28, 2026 at 4:54 am

    My main problem here was that I was trying to use the same model on both sides, the texture content is the compile time representation of the texture from my current understanding. So when I am in the compile-time domain of the Importer/Processor I can only work with these references and content data.

    So to solve my problem I had to revert back to using TextureContent and not Texture2D, then make a model SpriteMapContent which contained the references to the textures in question and the other data required for the model. Then write a content reader/writer to govern how the data was put together in the run-time domain.

    This similar post I made was what made it clearer to me where I was going wrong and what I needed to do to solve the problem.

    https://gamedev.stackexchange.com/questions/22480/contentserializerruntimetype-required-in-content-pipeline/22482#22482

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried to get my head around building a recursive function to handle
I have really tried to get my head around the first steps of understanding
I have an easy question that I can't seem to get my head around.
i have tried to get the sine wave example running on an AsioOut, but
I have tried using date(m/d/Y, strtotime(04-05-2012)) but I will get 05/04/2012 or on some
all. I've tried and tried to get my head around this, and feel I
This is probably a noob question but can't get my head around it. How
I'm still trying to get my head around using Java's generics. I have no
I can't get my head around quotes. EG, I have a string for an
I have a memory management problem I can't get my head around on iOS.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.