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 Shnayzr · Jul 03, 2015 at 09:26 AM · c#serializationdataserialize

how to serialize unity variables? (Sprite, Image ...)

Hello

currently i am doing C# serialization to save and load player data.

and i am following this tutorial http://gamedevelopment.tutsplus.com/tutorials/how-to-save-and-load-your-players-progress-in-unity--cms-20934

but how can i serialize Sprite?

edit#1: anyone know can i serialize a whole class? if i have a class full of variables how can i save all of them together instead of one by one

Comment
Add comment · Show 7
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 Hellium · Jul 03, 2015 at 09:29 AM 0
Share

Why would you serialize a Sprite ?

Can't you serialize its path in the resources folder and instantiate the sprite from it when you load your game ?

avatar image fafase · Jul 03, 2015 at 09:41 AM 0
Share

You could store the texture as a byte array which is already a first step.

avatar image Cherno · Jul 03, 2015 at 09:57 AM 0
Share

I support Hellium's suggestion. Just store the prefab name and/or path as a string, and use it to instantiate the prefab after deserializing. The only time I would consider storing the actual sprite texture is if it was generated at runtime.

avatar image Shnayzr · Jul 03, 2015 at 11:04 AM 0
Share

but what about other variables? GameObject, Transform ....

avatar image Cherno · Jul 03, 2015 at 11:19 AM 0
Share

Take a look here, where I explain how to serialize GameObjects, and other Unity-specific types like Transform and Vector3, with a sample project.

http://forum.unity3d.com/threads/serializehelper-free-save-and-load-utility-de-serialize-all-objects-in-your-scene.338148/

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Voxel-Busters · Aug 07, 2015 at 12:06 PM

Bump! Recently we released a serialization plugin which exactly does what you are looking for. Meet Runtime Serialization for Unity, fast and efficient tool to serialize c# objects as well as Unity objects like GameObject, MonoBehaviours. For compete list of support types, please check this link.

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

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

Related Questions

[Solved] Unity EditorWindow Serialization Problem. 0 Answers

Is there a serialization class similar to JsonUtility but for Byte Serialization. 1 Answer

Serialize class with serializable fields, 1 Answer

Serialization Data not working on Android? 2 Answers

Multiple Cars not working 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