Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by awplays49 · Apr 11, 2015 at 12:40 PM · xmlsupportxmlserializer

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.

Comment
Add comment · Show 5
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image meat5000 ♦ · Apr 11, 2015 at 02:31 PM 0
Share

Did you try this page?

It seems bare-bones enough to get a start at learning.

avatar image awplays49 · Apr 11, 2015 at 02:40 PM 0
Share

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.

avatar image meat5000 ♦ · Apr 11, 2015 at 03:11 PM 0
Share

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.

avatar image awplays49 · Apr 11, 2015 at 03:13 PM 0
Share

Ok I'll try. I'll get back to you with my progress.

avatar image awplays49 · Apr 11, 2015 at 04:53 PM 0
Share

@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.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges