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
1
Question by darthtelle · Apr 02, 2014 at 11:02 AM · saveloaddatawindows phone 8windows phone

Saving/Loading data to Windows Phone 8

I have successfully created a class which handles saving and loading a custom class for the vast majority of devices available (thank you to this great live training session).

 BinaryFormatter binaryFormatter = new BinaryFormatter();
 FileStream file = null;
 
 // Check whether a player file already exists
 if(File.Exists(Application.persistentDataPath + k_PlayerInfoFileName))
 {
     file = File.Open(Application.persistentDataPath + k_PlayerInfoFileName, FileMode.Open);
 }
 else
 {
     file = File.Create(Application.persistentDataPath + k_PlayerInfoFileName);
 }
 
 Player_Info data = new Player_Info();
 data.m_CurrentLevel = m_CurrentLevel;
 data.m_UnlockedLevel = m_UnlockedLevel; 
 data.m_LevelScores = m_LevelScores;
 
 binaryFormatter.Serialize(file, data);
 file.Close();

However, the process I've used (as demonstrated above) doesn't work with a Windows Phone 8. Is there an alternative class or method I can use which saves a custom class specifically for targeting WP8?

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

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by SimonDarksideJ · Jul 10, 2014 at 03:31 PM

Binary Serialisation is not supported on Windows Phone (the supporting classes are missing on there)

Use XMLSerialiser or other serialiser instead.

There is a nice JSON serialiser on the asset store which is pretty good.

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 08031992 · Apr 14, 2014 at 04:48 PM

Are you using "System.Io", if you are, it's not available to Windows Store Apps and Windows Phone 8 simply because this API doesn't exist in these platforms. It was replaced by the Windows.Storage API, and that's what you have to use for these platforms (WSA & WP8).

I'm getting stuck to this propblem too, if you find out some way, please tell me!

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 Dringy · Sep 14, 2016 at 12:30 PM

Windows phone is a bit funny with serialisation, you can't use System.IO for most things. You can either try using UnityEngine.Windows.File API or WinRTLegacy. I tried the former and it seems to work.

Found all the information for this On this Page.

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

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

Related Questions

How to save and load the game of the corresponding player by Serialization 1 Answer

How to save and load any data type? 1 Answer

Loading a list into unity 0 Answers

How can I save and load a player's position? 5 Answers

Saving a randomly generated Terrain 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