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 gennen · Aug 11, 2013 at 08:57 PM · game save

How to serialize and save for Win8?

Because .Net 4.5 blacklisted a bunch of old assemblies, all the ways I know for serializinf/deserializing and saveing/loading files don't work when building from Unity to Win8. I've been trying to figure out something new, but progress is slow because Mono runs on an earlier version of .NET so it allows things that I can't actually use. I would really appreciate some advice on fairly simple ways to serialize classes and save them out when making games for Win8.

Comment
Add comment · Show 2
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 Mithosbluefish · Aug 11, 2013 at 10:02 PM 0
Share

Hi, what are you trying to serialize/deserialize to/from? X$$anonymous$$L?

avatar image gennen · Aug 11, 2013 at 10:58 PM 0
Share

Anything at this point. I think I'd prefer JSON, but X$$anonymous$$L is fine.

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Mithosbluefish · Aug 11, 2013 at 10:16 PM

Here's a few methods that serialize and deserialize to and from XML using XmlSerializer, According to [msdn][1] it is supported in .Net 4.5, this will allow you to input the object you want to serialize and then serialize it into Xml and then input a XMLNode.OuterXML and a XMLSerializer (containing the node type) deserialize it.

  public XmlDocument SerializeObject(object pObject)
  {
      XmlSerializer xmlSer = new XmlSerializer(pObject.GetType());
      TextWriter textWriter = new StringWriter();
      xmlSer.Serialize(textWriter, pObject);
     
      XmlDocument xdoc = new XmlDocument();
      xdoc.LoadXml(textWriter.ToString());
      return xdoc;
  }
     
  public object DeserializeObject(string pXmlizedString, XmlSerializer xs)
  {
      MemoryStream memoryStream = new MemoryStream(StringToUTF8ByteArray(pXmlizedString));
      return xs.Deserialize(memoryStream);
  }
 
  byte[] StringToUTF8ByteArray(string pXmlString)
  {
      UTF8Encoding encoding = new UTF8Encoding();
      byte[] byteArray = encoding.GetBytes(pXmlString);
      return byteArray;
  }



Hope this helped :) [1]: http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx

Comment
Add comment · Show 4 · 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 gennen · Aug 11, 2013 at 10:58 PM 0
Share

Thanks so much, I'll try this out and let you know how it goes.

avatar image Mithosbluefish · Aug 12, 2013 at 12:24 AM 0
Share

Just tested a script using it in Windows 8 and it ran exactly as it should be :)

avatar image gennen · Aug 12, 2013 at 10:33 PM 0
Share

Do you mean it worked when running Unity on Win8 or that it works when you build to Win8? When I try to build that code as a Windows Store App it gets mad at XmlSerializer :(

avatar image Mithosbluefish · Aug 13, 2013 at 08:14 AM 0
Share

I used a build, as the only win8 pc I have handy doesn't have unity installed. Worked fine for me, if you want i can help you figure out whats wrong.

avatar image
0

Answer by Mithosbluefish · Aug 12, 2013 at 12:35 AM

Here's also something that might help you with JSON serialization. :) http://msdn.microsoft.com/en-us/library/bb412179.aspx

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 lancer · Aug 12, 2013 at 01:57 AM

There is a good Serializer I got from http://whydoit.com/. Very easy to use and well documented.

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

16 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

Related Questions

How do I save a unity web player game for offline play? 3 Answers

Saving GridBased map Best Practices 0 Answers

Save & Load function for Instantiated objects 0 Answers

Unity Serilizer taking to long to Save/load? 1 Answer

Saving some aspects of game (save strategy) 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