XNA Creators Club Online
Page 1 of 1 (6 items)
Sort Posts: Previous Next

XNA Unleashed book code

Last post 3/7/2010 5:55 AM by Unreal. 5 replies.
  • 11/21/2009 8:31 PM

    XNA Unleashed book code

    I am trying to try some xna unleashed book code.  I have all my classes, and no errors.  The only error I get is at runtime, and it is

    Error loading "Content\Skyboxes\skybox". File contains Microsoft.Xna.Framework.Graphics.Texture2D but trying to load as FinalWork.Skybox.

    Is this a known error, and what is the way of fixing it?  The classes it is sent to is

    public class SkyboxReader : ContentTypeReader<Skybox>
        {
            protected override Skybox Read(ContentReader input, Skybox existingInstance)
            {
                return new Skybox(input); //read data from compiled XNB format
            }
        }

        public class Skybox
        {
            private Model skyboxModel;
            private Texture2D skyboxTexture;

            // marked as internal since it is only called by our reader
            internal Skybox(ContentReader input)
            {
                skyboxModel = input.ReadObject<Model>();
                skyboxTexture = input.ReadObject<Texture2D>();
            }

    And the call is

    skybox = content.Load<Skybox>(@"Content\Skyboxes\skybox");

    The above call is just for a .tga file.  I dont know what is expected as I dont know what this ContentReader is.  Any advise appreciated.

     cheers
  • 11/21/2009 8:49 PM In reply to

    Re: XNA Unleashed book code

    change content.Load<Skybox> to content.Load<Texture2D> then try to run it.  If it generates another error somewhere else, Id assumemaybe you are missing a reference in your main startup project or a using namespace..
  • 11/21/2009 9:13 PM In reply to

    Re: XNA Unleashed book code

    I dont know if anyone knows the book, but it appears it was written for xna 1.0.  Would this be causing my problem?

    cheers
  • 3/5/2010 9:58 AM In reply to

    Re: XNA Unleashed book code

    I am having the exact same problem as nick2price. It is from the book Microsoft® XNA™ Game Studio 3.0 2009 edition. This problem is driving me crazy...
  • 3/5/2010 11:19 AM In reply to

    Re: XNA Unleashed book code

    erm your : ContentTypeReader<TRead> // says Skybox

    and should have a using statement of 
    using TRead = XELibrary.Skybox;

    Edit:- what about page 164 - did u do that? (Fired it up to see which one caused it to give that error, u not done page 164) changing the Content Processor part...
  • 3/7/2010 5:55 AM In reply to

    Re: XNA Unleashed book code

    Thanks Lowtechdog. 

    The problem was I was referencing the Skybox pipeline project in the References outside of the Content area. As soon as I referenced it inside the Content area I was able to change the Content Importer to the custom one.

    Thankyou!

Page 1 of 1 (6 items) Previous Next