• 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 /
  • Help Room /
avatar image
Question by Danteneo · Feb 21, 2016 at 02:09 PM · scenesavingscene loadloading fileload level

How to save a scene exactly as it is ?

Hello, I recently started a new game, and I have the following problem: I need to create the possibility to save the scene exactly in the state that it is at a certain point in time. That means the position of objects and values of variables. I have seen several examples on the internet but most them are saving only the position of objects and under certain conditions. The idea is that I already created the game and finished basically almost all of it, but it needs to be able to save the scene with everything exactly as it is, player condition and position, weapons, the number of bullets, all data about monsters position and situation, etc ... so is there any possibility to freeze the scene (on exit) and return to it when you reopen the game ? [sorry for any language mistakes I don't speak English very well]

Comment

People who like this

0 Show 3
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 Danteneo · Mar 14, 2016 at 02:19 PM 0
Share

No answers ... :( ... I guess there is no way to do it ... I read some more materials on the internet on this subject and I found out that in Unity to be able to save the scene with everything exactly as it is, player condition and position, weapons, the number of bullets, and other info from other objects all the data about them must be store manually using a special script for every intractable object that saves all that information from all the variables in a file or something .... this is so bad .... it's lame .... seriously

avatar image $$anonymous$$ · Mar 14, 2016 at 05:30 PM 1
Share

You'll have to do that manually, serialization is your friend.

avatar image Danteneo $$anonymous$$ · Mar 14, 2016 at 05:58 PM 0
Share

Thanks. I read some more materials on the internet on serialization and data saving in Unity. It is going to be a hard work to do this for every intractable object and for every parameter that I want saved .... but since this is the only way .... I don't have any choice.

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by toddisarockstar · Mar 14, 2016 at 09:19 PM

this is how you do it. you whould collect all the positions weapons, rotations blah, blah, of all your objects in some sort of format. I would recommend maybe a text file with bunches of numbers seperated by commas in some format you create based on what your game needs and a format to your liking. your game would look for the file when the the game reopens. and obviosle you would then split with separators and manually move the numbers into spawn functions and reasign whatever nessesarry variable in your game. If you are Building for windows or mac its perty simple to access a hard drive to write your custom file. web players are tough. firewalls like to block these sort of things. you might need to read/write to a website or server for a webplayer game. there is no easy or automatic way to do what you are asking.

Comment
Danteneo

People who like this

1 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 Danteneo · Mar 14, 2016 at 09:29 PM 0
Share

Thanks. I read some more materials on the internet on serialization and data saving in Unity. It's a lot of work when you have many objects of different types but maybe I can come up with some crazy algorithm to solve it in an clear and nice way .

avatar image toddisarockstar · Mar 14, 2016 at 10:19 PM 1
Share

eh, really you would just write the relevant stuff. for example you pry wouldnt really need to save player rotation, pry just location....maybe even rounded off. if he ad a gun, and there was say 4 different guns all you would need is one number 1 to 4. I can post a simple code example to read/write to a harddrive from my last game if you want. if your game is not multiplayer it might be a bit simpler than it sounds just to snap player to positions with scores and stuff

avatar image toddisarockstar · Mar 14, 2016 at 10:24 PM 1
Share

you wouldnt bother saving anything about the level unless its randomly generated or something like that. you could toss in a couple numbers to represent a tree knocked over or something like that.

avatar image Danteneo toddisarockstar · Mar 15, 2016 at 11:51 AM 0
Share

Thanks! I found some good examples on serialization and managed to save the player data, now I have to do it for intractable objects and some enemies.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

46 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 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

How do you keep keystates between scenes? 1 Answer

Is there a way to save a scene in a current state? 0 Answers

How's my SceneManager? 0 Answers

Unity not loading scene 0 Answers

Game crashes on mobile 0 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