Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 KnightRiderGuy · Sep 12, 2015 at 06:58 PM · timerdatascene-switchingsingletontimers

Timer Data Across Scene Changes

Ok been struggling with this for a while now. In my main scene I have a trip timer that can be started, paused and stopped and reset. When I go to another scene and then come back to my main scene I loose the time on the timer, I have heard that Singletons are a way to solve this. How would I do this using U.I. text?

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
0

Answer by SarperS · Sep 12, 2015 at 07:11 PM

Set your timer script to not destroy on load so it will persist between scene changes.

http://docs.unity3d.com/ScriptReference/Object.DontDestroyOnLoad.html

Comment
Add comment · Show 6 · 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 KnightRiderGuy · Sep 12, 2015 at 08:32 PM 0
Share

Thanks Sarper but I don't want my timer to persist, I just want it to continue counting and keep accurate time when I return to the scene that has the timer in it.

avatar image SarperS KnightRiderGuy · Sep 12, 2015 at 08:36 PM 0
Share

Why not? $$anonymous$$aking it persistent is the easiest way. If not I would store the timer value and Time.time before changing the scene in two static variables. Upon returning to that scene I would assign (Time.time - storedTime) + storedTimerValue back to it.

avatar image KnightRiderGuy SarperS · Sep 12, 2015 at 08:43 PM 0
Share

I'm not sure I'm making myself clear. lol O$$anonymous$$ lets try this: I have a timer stop watch style in scene one or my main scene. I want for when I go back to my main scene for the timer to still be running and keeping an accurate "Count Up" of time.

I also have another one that can be set as a "Count Down" timer.

If I was to set them both and then leave that scene to go to another scene and then come back I would like them to have been running all during that time and keeping accurate to either Count Up or could down or both depending on if I have set one or both.

now I have heard that singletons are a way to do this but I am finding nothing on how to do any of that using UI text on canvases ?

Show more comments
Show more comments
avatar image getyour411 · Sep 12, 2015 at 08:34 PM 0
Share

@zentaiguy - that's persist.

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

28 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

Related Questions

How do I implement a timer into this script that will record the total time the player has played. 2 Answers

Big problem with a small singleton 1 Answer

How to add a delay to a bomb explostion 1 Answer

How to make reverse countdown timer in unity? 1 Answer

jump timer 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