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 AtomicMarine · Nov 22, 2011 at 08:44 AM · playerprefsloadingsavingminecraftblocks

Saving Scenes and loading GameObjects?

I have a scene where the player is able to slowly generate more content (like a sim builder), and I need this scene to save the instantiated prefabs for when he/she logs in or out.

The problem I am experience goes two ways, when I use the "don't destroy on load" method the prefabs inter fear with my other scenes (obviously because they are not being destroyed).

So what I'm asking, am I supposed to save each objects position, and how many of that object here are, and re-instantiate each object every time the player reloads the scene? are there easier ways to do this? think about how mine craft keeps the position of all its blocks when the player logs out and back in? is there a way to save a whole scene and reload the whole scene as is or is it more complex?

Comment
Add comment · 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 brumdogpro · Nov 24, 2011 at 04:50 AM 0
Share

I've never heard of saving the entire scene but I recommend if it isn't too much, you can try creating PlayerPrefs and just reloading them whenever the player gets back on. Or just set the scripts to not interfere with other scenes.

avatar image AtomicMarine · Nov 24, 2011 at 07:27 AM 0
Share

It's turning out to be like 100 objects , I may make a player pref array, or I might just save all the info into a database and withdraw it with SQL and what not

avatar image cregox · Apr 20, 2012 at 03:28 PM 0
Share

Troubled question. Are you having problem with DontDestroyOnLoad or with saving your game state when closing and reopening the application?

4 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by cregox · Apr 20, 2012 at 06:32 PM

If you want to save state between closing and reopening the application, `PlayerPrefs` is the way to go (or maybe PlayerSave, or even XML's or databases). And yes, you'd have to save each thing you want, one by one (make it in the suggested array) and there's no current easier way of doing it.

If, however, you're having issues with DontDestroyOnLoad, conflicting objects, you have to review your scene & code and remove the conflicts one by one.

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 AtomicMarine · Apr 27, 2012 at 02:16 PM 0
Share

PlayerPrefs would require me to use hundreds of variables if I was saving and loading them out individualy, $$anonymous$$y best solution to this was to use player prefs however Ins$$anonymous$$d of saving 1 number each to a different player pref I saved a string of letters and numbers usually 40 characters long, to one player pref, then I used an array which would get each different value out of the pref and resort them into their correct places, so yes Player Prefs is the easier solution to this but it is by no means easy.

avatar image
2

Answer by Steven-Walker · Apr 20, 2012 at 03:41 PM

Saving a scene is an editor function that will only work while running Unity. So you will need a different solution when it comes to deploying an app to any platform. I'd suggest writing data to either JSON or XML using the shortest fastest form possible. A database would work well too. Your scene then in Unity will just be the core elements and source prefabs. When your scene loads, the script will have to take care of instantiating all of the prefabs with the data saved previously. I also suggest starting with something really simple and test it on your target platform before getting too far building stuff in the editor.

Comment
Add comment · Show 2 · 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 AtomicMarine · Apr 27, 2012 at 02:14 PM 0
Share

No, what I am talking about is a Player saving a game as an in game function, for example like saving the game while playing diablo 1 then being able to load everything as it was the next time the player loads into the game.

avatar image AtomicMarine · Apr 27, 2012 at 02:18 PM 0
Share

I considered databasing it, but see my comment on Caue Rego's answer, as that was the easiest solution as databasing is a difficult thing to achieve when using IOS Xcode functionality

avatar image
1

Answer by Propagant · Jan 09, 2016 at 05:07 PM

Hi. I made a long script with advanced load and save system. Everything is about File stream. Every position, rotation and scale (basic datas of every object) are saved to txt file as a new Line.

You can save and load your instantiated objects. But first, if you want to load different meshes except Cube, you must create Resources folder in your assets project and duplicate meshes which will be loaded in a future.

Also you can set which objects will not be saved or loaded. You can edit script also, it is free and my without copy... Download here: Save_Load Advanced System by Matt DOWNLOAD


save-load-system-v2.zip (4.1 kB)
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 TheDarkVoid · Apr 20, 2012 at 08:13 PM

add and if block around your don't destroy on load function to control when it is applied.

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 AtomicMarine · Apr 27, 2012 at 02:17 PM 0
Share

This doesn't work as when the player quits the game, and reopens, all the objects die anyways, also the objects then stay present in the other scenes which have nothing to do with that game mode.

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Saving with PlayerPrefs? How it works? 1 Answer

PlayerPrefs not saving mission info at all. 0 Answers

PlayerPrefs logic and bool? 1 Answer

Save/Load Animation State of Instantiated Prefabs 0 Answers

playerprefs multiple save slots 2 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