Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 marco · Mar 09, 2010 at 12:31 AM · iphonefile-io

fileio System.Xml

hi unity(users),

After the release of Unity iPhone 1.6, I spend days looking for answers on the internet fora.

It's about C# FileIO. I know it is(was?) not possible in Basic... But... version 1.6 came along!!! And this little sentence in Unities announcement made my day:

System and System.Xml can now be used without stripping. Useful for Basic license owners.

I could not wait to install version 1.6. Suddenly, Unity became seriously useful for iPhone development!

But... whatever i tried nothing worked. The code below works fine in the editor, but trying to test it on the iPhone results - after packaging - in an error message, something like 'Sockets are only available in Advanced ...'

To make a long story short, unity iPhone basic can be very useful for my company if there is some basic fileIO. (paying 2 times 1000 euro's - just for fileIO in my case - is a bit too much these days)

Please, can anybody shed some light? Is there something wrong with this code? Or System.XML is still not useful in Basic?

thanks in advance - marco

BTW I know PlayerPrefs do work, but i need more space.


the test code:


using UnityEngine; using System.Collections;

using System.Xml;

public class Msg : MonoBehaviour {

static private Msg instance = null;

static public void set (string text) { Msg msg = GetInstance(); if (msg != null) msg.guiText.text = text; }

static public void Clear () { set(""); }

static public void add(string text {

  Msg msg = GetInstance(); 
  if (msg != null) msg.guiText.text += (text+"\n"); 

}

static public Msg GetInstance() {

if (instance == null) { instance = (Msg)FindObjectOfType(typeof(Msg));

  if (instance == null) { 
     Debug.Log ("Could not locate a SimpleLogger object."); 
  } 

} return instance;

}

void OnApplicationQuit() { instance = null; }

void Awake() {

Clear(); string s=Application.dataPath;

add(s.Substring((int)Mathf.Max(0,s.Length-60))); testWriteXml(); testReadXml();

}

private void testWriteXml(){

XmlTextWriter textWriter = new XmlTextWriter(Application.dataPath+"/myXmFile.xml", null); // Opens the document textWriter.WriteStartDocument(); // Write comments textWriter.WriteComment("First Comment XmlTextWriter Sample Example"); textWriter.WriteComment("myXmlFile.xml in root dir"); // Write first element textWriter.WriteStartElement("Student"); textWriter.WriteStartElement("r", "RECORD", "urn:record"); // Write next element textWriter.WriteStartElement("Name", ""); textWriter.WriteString("Student"); textWriter.WriteEndElement(); // Write one more element textWriter.WriteStartElement("Address", ""); textWriter.WriteString("Colony"); textWriter.WriteEndElement(); // WriteChars char[] ch = new char[3]; ch[0] = 'a'; ch[1] = 'r'; ch[2] = 'c'; textWriter.WriteStartElement("Char"); textWriter.WriteChars(ch, 0, ch.Length); textWriter.WriteEndElement(); // Ends the document. textWriter.WriteEndDocument(); // close writer textWriter.Close(); }

private void testReadXml()

{ // Create an isntance of XmlTextReader and call Read method to read the file XmlTextReader textReader = new XmlTextReader(Application.dataPath+"/myXmFile.xml"); textReader.Read(); // If the node has value while (textReader.Read()) { // Move to first element textReader.MoveToElement();

         add("Name:" + textReader.Name);

     }
 }

}

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Mantas-Puida · Mar 10, 2010 at 02:21 PM

It looks to me as a bug. We will investigate this issue.

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 Wozik · Mar 31, 2010 at 04:28 PM

fixed for next Unity iPhone release

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

No one has followed this question yet.

Related Questions

Is there a method for getting application saved data off the iPhone? 2 Answers

iPhone System.IO.File.Exists() not working 1 Answer

How can I Javascript a phone call from within Unity? 1 Answer

iOS Target Resolution doesn't seem to affect resolution 0 Answers

how to store and retrieve data from sqlite in android and iPhone? 7 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