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 Redaa · Apr 28, 2015 at 09:00 PM · unity 5serializationunity serializer

Issues when using Unity Serializer

Hello i'm using the 3rd part plugin "Unity Serializer" Which is available on the asset store and all people are pointing to it, my problem is that I can't get this plugin to serialize my class, i don't need to add the stuff in the editor ... I just need Storage.serializetostring(myObject). That's all.

So i downloaded the asset extracted it and i just imported the whydoidoit which i believe contains the necessary classes for serializing, After that i went to Visual Studio and marked the property of the class i wanted to serializable with "SerializeThis", but when i call Storage.serializeToString(myObject) it always return a constant string, I tried to create a new class with just properties of int and string thinking that the problem might be the properties of my class (GameObject, lists ...) but SerializeToString always returning the same value no matter what object is passed.

I think i should add some code snippets my C# code will be better than my English :D :

TestClass.cs:

 using UnityEngine;
 using System.Collections;
 
 public class TestClass : MonoBehaviour 
 {
 
 // Use this for initialization
 public int score { get; set; }
 public string Name { get; set; }
 public string Message { get; set; }
 }​

SerializationHelper.cs : this class is static and allow me to use the Unity Serializer class

 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using UnityEngine;
 using Serialization;
 using Assets.Scripts;
 
 public static class StorageHelper
 {
 public static void SaveLevel(Level level)
 {
 TestClass test = new TestClass();
 test.score = 10;
 test.Name = "reda";
 test.Message = "Hello";
 var repre = Storage.SerializeToString(test);
 Debug.Log(repre);
 }
 }​


If you guys know what's the problem here, please share your knowledge, also am new to here so if I did a mistake I will edit it, Thanks in advance.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Apr 28, 2015 at 09:43 PM

I haven't really used this serializer yet, but what i can tell right away is that you're doing something fundamentally wrong ^^. Your class is derived from MonoBehaviour. That makes this class a component. Components can't be created with "new". You should actually get a warning about that.

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 Cherno · Apr 28, 2015 at 11:40 PM 0
Share

Yeah... Also, don't use Unity Serializer. It was a decent asset years ago, but support has been dropped and the website with forum full of valuable information as well as the API has been down for a few weeks. Critical bugs were never corrected, once your project gets a little bit more complex, with lots of gameobject references between classes, you will get errors that corrupt your save files (been there, done that). However, the LevelSerializer.cs script is an excellent source for your own serialization efforts, if you decide to go down that route.

Top: The SerializeField function at the very bottom are nowhere used in US, but they nevertheless provide a good starting point. Combine it with ISerializationSurrogates and you have a simple and robust serialization system.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Using UniFileBrowser and LoginPro to upload file = zero bytes uploaded? 0 Answers

How to protect JSON file game data? 3 Answers

Is it possible to use DataContractJsonSerializer? 2 Answers

IO Exception: Sharing Violation on Path,IOExeption Sharing Violation on Path 0 Answers

Save and Load all spawned objects in their position using array 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