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 united4life · Apr 17, 2013 at 06:26 PM · gameobjectsave

How to save a Gameobject?

There are 4 sets of gameObject A,B,C,D and there are 4 sets of color red, black, white, brown and there is one trigger to check which gameobject has entered. Now suppose A has entered the trigger and now i click on red, now the A gameobjects material is red. Now when i click on save button this A gameobject with new rendermaterial should be saved. So next time when i play the game i should be able to see the saved gameobject. How to achieve this? I feel PlayersPrefs will be involved.

Comment
Add comment · Show 2
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 united4life · Apr 18, 2013 at 05:54 PM 0
Share

Any idea how to achieve this...?

avatar image hoy_smallfry · Apr 18, 2013 at 06:23 PM 0
Share

As far as I know, there is no direct way to save the state of a game object while the game is running. Doing so would require you to overwrite the scene or the prefab file, whichever was used by the player to deserialize the game object.

What you want is essentially saving and loading a game state. There are plenty of answered questions on how to that, like this one:

http://answers.unity3d.com/questions/8480/how-to-scrip-a-saveload-game-option.html

Look around the site, you might get a better idea of what you have to do to get your desired effect.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by DaveA · Apr 18, 2013 at 06:44 PM

Yes you could use PlayerPrefs. I would make each object have a unique name, and use that as the key. And each material should have a unique name, and use that name as the value, save the pref as a string. When you restart the game, read out each object name as the key and the value is the name of the material, then set the material from 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 united4life · Apr 18, 2013 at 08:20 PM 0
Share

I dont know how to use $$anonymous$$ey. So you are telling me for the colors give playerprefs.setint and for each object playerprefs.string ?

avatar image
0

Answer by kilian277 · Apr 18, 2013 at 08:57 PM

You can use the PlayerPrefs class for that. For each color of the gameobject set an int or string based on how yoy want to store it and give it an unique id or key like object1Color. To this for everything you want to store from the gameobject for future use ingame.

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

14 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

Related Questions

Don't Load Collected items 1 Answer

save/load cloned game object 1 Answer

Save gameobject active 1 Answer

Storing GameObject(s) Playerprefs? 1 Answer

How to save a gameObjects on a prefab and variables with a script? 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