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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
1
Question by IvanHalimXTR · Dec 09, 2013 at 04:44 PM · c#xmldatabase handlingwrite data

how to create xml file and read xml file in C# ? Unity

I need a function to create a xml file so i can produce my cardgame data to xml and I need a function to load a xml file to read my cardeffect.xml and able to access it using another gameObject.

my cardeffect.xml

 <catalog>
 <deckregion name="Phoenix">
 <card no="1">
 <type name="Action Card">
 <name>Burning Waves</name>
 <effect>500 damage to target</effect>
 <costMP>300</costMP>
 </type>
 </card>
 </deckregion>
 </catalog>

I need some help to read this xml using C# , and how i able to load it into variable that i need?

Comment
Add comment · Show 2
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 IvanHalimXTR · Dec 09, 2013 at 05:59 PM 0
Share

I try the code and attached to game object , after that i create SaveData.xml to assets folder but when i run it display this error warning The class defined in script file named 'SaveData.xml'does not match the file name!

avatar image AndrewBilotti · Jan 13, 2016 at 03:03 AM 0
Share

good question :D

3 Replies

· Add your reply
  • Sort: 
avatar image
9

Answer by TonyLi · Dec 09, 2013 at 05:19 PM

Follow this tutorial: http://wiki.unity3d.com/index.php?title=Saving_and_Loading_Data:_XmlSerializer

Or Microsoft's: http://msdn.microsoft.com/en-us/library/182eeyhh%28v=vs.110%29.aspx

In brief:

  1. Add your XML file to the project. It will be a TextAsset.

  2. Define a class with a [System.Serialized] tag at the top.

  3. Use XmlSerializer.Deserialize (as shown in the bottom of this page) to read the XML TextAsset into an instance of the class.

We can point you in the right direction, but unityAnswers isn't the place to ask for someone to write code for you. If you want to hire someone to write the code for you, you can post in the Commercial: Job Offering forum.

Comment
Add comment · Share
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
0

Answer by zombience · Dec 09, 2013 at 05:11 PM

Check into the load/save package that is on the unifycommunity, it is written in C# (and JS) and can help you understand what you might need to do. It should provide a framework for everything you're trying to do, and is modifiable in case you need more.

http://wiki.unity3d.com/index.php/Save_and_Load_from_XML

Comment
Add comment · Share
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
0

Answer by zzeeshann · May 26, 2016 at 07:46 PM

Check out this video tutorial

https://www.youtube.com/watch?v=nYWlB7HRNSE

Comment
Add comment · Show 1 · Share
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 KenSAE · Apr 06, 2018 at 07:21 AM 0
Share

i have gotten this far, but i am struggling to assign the data from the list to variables inside a class.

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

21 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 avatar image avatar image

Related Questions

Read AND Write to XML at runtime 1 Answer

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Xml Serialization? (how to read/write?) 1 Answer

Dtd validation with TextAsset xml gives exception 0 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