Sign in to follow this  

[XNA] Default XML Values

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;


    // 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);

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this