- Home /
Confusion with process of XML setup
HI,
I have a bit of confusion about XML. I'm very new to XML, and I am staring at a screen of code tutorials whereas they don't tell me what each part of code does, and what I have to do specifically.
Let's say I had many cubes in my game with different data values. I want to save the x, y and z position of each.
Im confused on this part. The first Part:
using System.Xml;
using System.Xml.Serialization;
public class Monster
{
[XmlAttribute("name")]
public string Name;
public int Health;
}
That is from the wiki site. I have no idea what it means and I don't know what I put in the "name" part. Is it important? What do I put as the variables? Why are there square brackets? I thought those were just for arrays... I am completely lost and I have no idea what to do so I really need some support. Thanks.
Did you try this page?
It seems bare-bones enough to get a start at learning.
It looks like that page uses TextAssets. Someone told me to steer clear of those. Thanks for your effort though, I really do appreciate it.
I am trying to follow along to the wiki page. Here is what I've got
using UnityEngine;
using System.Collections;
using System.Xml;
using System.Xml.Serialization;
public class Cube$$anonymous$$onster : $$anonymous$$onoBehaviour {
[XmlAttribute ("Name")]
public string Name;
public int XPos;
}
and this
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Xml.Serialization;
[XmlRoot ("$$anonymous$$onster Collection")]
public class X$$anonymous$$LContainer : $$anonymous$$onoBehaviour {
[XmlArray ("$$anonymous$$onsters")]
[XmlArrayItem ("$$anonymous$$onster")]
public List <Cube$$anonymous$$onster> $$anonymous$$onsters = new List <Cube$$anonymous$$onster> ();
}
But I have no idea what to do with each script, and what the next step is. You're a coder, so I'll bet you've been in a similar situation. Do you know the feeling where you want to learn something every step of the way and you just want an in-depth tutorial, but there isn't one, so you just feel hopeless? That's how I feel right now. I really want to grasp the concept completely like I have so far. That's why I post so many questions.
Start with the page I linked. TextAssets or not, its a basic page for you to get to grips with easier parts of Unity:X$$anonymous$$L.
Just follow it through and see how the X$$anonymous$$L and unity script link up.
@meat5000 I can''t follow along with it, it's doing the same thing as the wiki. What objects do I attach each to? Do I make an empty game object? are they all different scripts that attach to the same object? is that object in game already? Do they go to different objects? I'm so confused.
Your answer
Follow this Question
Related Questions
unity and xml question 1 Answer
Parse XML to Vector3 (and other objects you don't control) 0 Answers
Help with XML reading and writing 1 Answer
Deserializing data with XML Serializer 0 Answers
Need help in appending to Xml document 3 Answers