- Home /
How add Windows.Storage as a reference
I'm making a game that I plan to release on Windows Phone. The problem is that when using normal saving API's like xml or System.IO it doesn't work on Windows Phone. I've looked up the solution to saving user data on Windows Phone(Without using Player Prefs as that would be inefficient and insecure), and have found that the API Windows.Storage is to be used.
However, when I go under Project -> Edit References in MonoDevelop there is no Windows.Storage or Storage in the list. I've even tried to find the physical DLL to reference, but haven't been able to get the correct one.
So how can I reference Windows.Storage for use?
Answer by xortrox · May 12, 2015 at 10:52 AM
4th url when googling "unity windows phone windows.storage": http://answers.unity3d.com/questions/579641/handling-the-lack-of-systemio-classes-in-windows-8.html
I've read this post before and it doesn't say how to reference. It simply writes using Windows.Storage in the script which I have tried and can't get to work.
As the last non accepted answer on that page mentioned: http://blog.ashwanik.in/2015/03/Fileoperations-on-windows-phone-and-windows8.html
I just tried that out in as simple a way as I could(moneyText.text being the text component of a UI textbox) -
using UnityEngine.Windows;
void OnApplicationFocus(bool focusStatus){ if (focusStatus == false) { File.WriteAllBytes("SaveData1", new byte[] {69, 2, 3}); } else if(File.Exists("SaveData1")) { moneyText.text = File.ReadAllBytes("SaveData1")[0].ToString(); } }
I tested it on my computer which worked then built it on a Windows 8.1 Phone which didn't work, so I still need to use Windows.Storage I think.
Try using the WriteAllText version ins$$anonymous$$d as only this and the other ReadAllText actually check if you're in windows phone or not. I would guess this is what makes it work or not.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How do I stop jumping mid air? 5 Answers
How to get step sound using axis.x movement 2 Answers
Distribute terrain in zones 3 Answers
How to let other object know i have enter a collider of a different object 1 Answer