Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 Moubien · Nov 11, 2016 at 11:31 PM · gameobjectscene

Regarding setActive

Hi, I have an issue that I can't find a solution for it, I have two panels on top of each other and depends on a button press I do setActive(true) and the other is false the problem is when I go to different scene and go back to this scene the change isn't saved and I go back to what it was originially any helpful tips please?

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

4 Replies

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

Answer by MrKagouris · Nov 12, 2016 at 07:37 AM

You can use this to save data across sessions (and thus scenes). It only saves ints, floats and strings though, so you might need to get a little creative to make it save and load a GameObject's Active state.

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 Moubien · Nov 12, 2016 at 10:07 AM 0
Share

I followed your advice to be creative and you were right it wasnt related to PlayerPrefs I just need some static flags to hold the state of it and a test condition for these flags to set the corresponding panel to be active

avatar image
0

Answer by FiveFingerStudios · Nov 12, 2016 at 09:22 AM

Whenever you load a scene, it loads at how you left it when you last saved. That means if you change something and don't save the scene, it will now save the change.

You would need to save the setActive state to disk, or a singleton that remains alive between scenes.

If you want to do a permanent save (between robots of your computer) you need to save to disk. One easy way is to you "PlayerPerfs" to save and load the state.

A singleton object can store between scenes but requires a little bit more programming knowledge.

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 nomischen · Nov 12, 2016 at 07:56 AM

To save data between Scenes, its easy to use

 PlayerPrefs.SetInt("VariableName", VariableValue);
 int HealthorWhatever = PlayerPrefs.GetInt("VariableName");


That data also saves when you exit, Its useful for savegame. But if you're saying the scene isn't saved, save the scene with Ctrl+S

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 James-Laker · Nov 12, 2016 at 07:39 AM

You can use the PlayerPrefs for that. You should try and keep it small from what I remember.

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

7 People are following this question.

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

Related Questions

Add mesh with materials to scene through code. 0 Answers

When ai (capsule) touches gameobject reset scene. The code does not work, and there is no errors any suggestions 1 Answer

How to access a game object from a different scene? 0 Answers

How do I play gameobjects in my scene from one script / Script is not working 0 Answers

Save levels gameobjects when closing game/leaving scene 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