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 RobDog · Feb 24, 2013 at 07:58 PM · iospersistentdatapath

persistentDataPath not working on iOS. UNITY 4.PRO.

Trying to save replay data to the device. It works on the Editor, works on Mac builds, works on Android. but doesnt work on iOS.

Im on UNITY 4.0.1f2 ..Pro for everything.

Ive read a bunch about the data path issue on the net..but they all say that since 3.3, Unity will add the /Documents path to the iOS builds..

i displayed the filepath on the iOS device when it read/writes and its correct.

/var/mobile/Applications/xxxxx-xx-x-xx-xxxx/Documents/Replay_1.bin

         string dataPath = Application.persistentDataPath;
         string filename = dataPath+"/replay_"+this.gameLevel+".bin";
         Debug.Log ("Loading from DISK!"+filename);
         
         this.myDebug.text = filename;
 
         using (Stream stream = File.Open(filename, FileMode.Open))
         {
             BinaryFormatter bin = new BinaryFormatter();
             this._gameCommandList = (List<GameCommand>)bin.Deserialize(stream);
             stream.Close ();
         }

and for saving..

         string dataPath = Application.persistentDataPath;
         string filename = dataPath+"/replay_"+this.gameLevel+".bin";
         
         this.myDebug.text = filename;
         
         Debug.Log( "Saving to disk!" + filename);
         using (Stream stream = File.Open(filename, FileMode.Create))
         {
                 BinaryFormatter bin = new BinaryFormatter();
             bin.Serialize(stream, this._gameCommandList);
             stream.Close ();
         }

P.S. i tried doing a search on this website..but the server times out :(

so close..yet so far..

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
0

Answer by RobDog · Feb 25, 2013 at 03:36 PM

ok..think i found out the issue..

i wrapped the code with try/catch blocks..

printing out the exception didnt tell me anything.. so i had to dig in deeper and print out the innerException message.

which told me that it could not JustInTime compile my << List >> .. and thats its in AOT-ONLY something or other..

AOT = Ahead of Time compiling.. the iPhone (Apple) does not allow JustInTime compiling on the device..

Now.. if you start searching Answers with key works "iOS JIT AOT".. you get a bunch of hits! All the different ways Unity/C# is trying to JIT on an iOS device.

Oh well.. pretty bummed since that serialized code above was SOOO DAMN easy. now i gotta go "OLD SCHOOL" on it.

based on reading a few of those hits..im going to guess this JIT/AOT thing is going to bite me again.. test test test test ! especially on the devices! and throw a crap load of try/catches in your code

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 hamstar · Mar 31, 2014 at 06:24 AM 0
Share

@RobDog You might find this useful: http://answers.unity3d.com/questions/30930/why-did-my-binaryserialzer-stop-working.html

avatar image
0

Answer by Tasmia · Mar 31, 2014 at 07:32 AM

I was facing same issue.My ProductName was wrong,containing space, used for bundle identifier, to get persistentDataPath. so I resolved my 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

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

11 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

Related Questions

How to download asset bundles and storing it locally in ios 0 Answers

Application.persistentDataPath not working on ios but working on Mac Editor and Android 1 Answer

Delete screenshots from Gallery 0 Answers

Persistent data path changes every time a new version of the IOS app is generated 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 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