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 zupermario · Mar 10, 2014 at 11:49 PM · iosxmlread

Write and Read to a iOS device! Help

Hi everyone!

I've been working on a code for 1 1/2 day to use on iOS device. I've been using testing it on a mac, but switching it iOS didn't go well. I thought i could just switch from using Application.dataPath to peristentDataPath and it would work. But NO!

I'm not familiar with using a serializer, so i followed this example http://unitynoobs.blogspot.no/2011/04/xml-writing-to-existing-xml-file.html.

I used a StreamWriter and created a .txt file, is it a way to use these together.

I would really be greatful for a simple but a full example how to get this done :)

Thank you in advance.

Comment
Add comment · Show 3
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 knunery · Mar 11, 2014 at 12:37 AM 0
Share

What broke when you changed to ios? Can you post the error message? I would suggest making it work on $$anonymous$$ac with Application.persistentDataPath and then it should work on ios (with a couple of caveats).

avatar image zupermario · Mar 11, 2014 at 04:52 PM 0
Share

Well i'm using X$$anonymous$$LDocument. xmlDoc.Load(filepath); xmlDoc.Save(filepath);

So on my mac i use string filepath = Application.dataPath + @"/Data/gamexmldata.xml"; Tried to use on my mac and it didn't work. string filepath = Application.persistentDataPath + @"/Data/gamexmldata.xml"; But it failed, i just a IF statement to chech if the "filepath" exist. On mac with dataPath works, but with persistentDataPath doesn't work.

Tried to use it on ipad and didn't work either. :(

avatar image whydoidoit · Mar 11, 2014 at 05:59 PM 0
Share

You made a Data folder with CreateDirectory inside your Application.persistentDataPath right?

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by knunery · Mar 11, 2014 at 08:32 PM

This save method works for me on both my mac and iphone.

 public void Save() {
     Debug.Log (Application.persistentDataPath);
     
     XmlSerializer xml = new XmlSerializer (typeof(PlayerData));
     FileStream file = File.Create (Application.persistentDataPath + "/playerInfo.dat");
     
     xml.Serialize (file, playerData);
     
     file.Close ();
 }
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

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

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

Related Questions

Writing a XML file to iOS 1 Answer

Saving My World 1 Answer

XmlException when trying to read/write XML from iOS device 1 Answer

Using XML for a simple webplayer Highscore Table 1 Answer

Work with XML hidden for the user? 1 Answer


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