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 RealMTG · Aug 22, 2014 at 02:04 PM · binarywriter

Using BinaryWriter/Reader to save levels?

Hi!

I have recently come across BinaryWriter and BinaryReader. What I can tell so far, you can save information with it. If I am wrong, please tell me! But if this is the case, would it be possible to use it to save levels for a level editor? Like saving all the items and objects the player put in the scene. How would I do it? And how would I read it? I have been searching for some information about this for around 30 minutes and I will keep looking for a while.

If you don't want to read the whole text, just answer these questions.

Is is possible to save all the objects in a scene to a custom format? Example: mylevel.gamelvl

How would I save it?

How would I read the information in the file so everything would appear in the game again?

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
1
Best Answer

Answer by Cherno · Aug 22, 2014 at 03:10 PM

It's certainly possible and in fact it's relatively easy.

Before continuing: Have a look at Unity Serializer, it is a free all-in-one package that saves and loads everything your want. If you decide to use it, also have a look at this link.

Now, as for custom serialization, the basic code is as presented in this Stackoverflow thread and also this link.. I hope it's ok to just hrow a bunch of links at you, but of course this has been done multiple times, including with Unity, so it's best to see how others have successfully done it :)

Tha way my level save and load features work is that I have everything that needs to be loaded as a prefab, and it has a script that holds a unique ID when the object is created the first time. When saving, the custom savegame class holds an array of all the objects with their corresponding IDs and which prefabs they are. When loading, this inforatmion is used to instantiate the objects again. Things like position, rotation and any custom attributes can of course also be serialized (How to serialize any variables of a class, look at yet another thread! :D

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 RealMTG · Aug 22, 2014 at 10:01 PM 0
Share

Thank you! $$anonymous$$uch appreciated! I will check all these out and see if I can get something to work!

Also, it is ok to throw links at me. :P

Thanks again!

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

BinaryReader not returning anything 0 Answers

Why does BinaryWriter allocate memory when writing floats? 1 Answer

Problem with my binary files 1 Answer

How to save a ui button for binary formatter 2 Answers

upload file using binarywriter to server 3 Answers


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