• Advertisement
Sign in to follow this  

[XNA] Default XML Values

This topic is 2900 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, Is it possible to set up an XML to have default values for certain elements? What I am trying to do is add a new member to my base game object class. These objects are initialized by reading in XML data into a Definition class.
    public class GameObjectDefinition
    {
        // The position of the object in the world.  In the case of a 2D
        // element, the Z component will be ignored.
        //
        public Vector3 mPosition = Vector3.Zero;

        // The pitch, yaw and roll of the object in the world.  In the case
        // of a 2D element, the rotation will be based around the Z axis (roll).
        //
        public Vector3 mRotation = Vector3.Zero;

        // The scale of the object, with 1.0 being equal to it's original value.
        //
        public float mScale = 1f;

// !! THIS IS WHAT I AM ADDING !!

        // The priority is used to decide what order the object is rendered.  Most of
        // the time this can just use the default value.
        //
        public int mRenderPriority = 100;
    }
But I don't want to have to go through every existing XML file in my project and add the mRenderPriority element, just to assign it a default value. I'd like to just add it to the Game Object who want a value other than what I deem the default value. Is this possible? I get this error if I don't add it to any XML files:
Error	1	XML element "mRenderPriority" not found.
I load the XML data using the XNA Content Manager:
            GameObjectDefinition definition = GameObjectManager.pInstance.pContentManager.Load<GameObjectDefinition>(fileName);
Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement