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 · Jan 26, 2016 at 03:47 PM · c#scene-loadingtoggle buttontimers

Start Something on Main Scene Start Up

Ok I know we can use the void Start to make something happen right away or on the void Awake but what if I want to do something when my main scene loads in something like this with a toggle button:

 IEnumerator AutoStartTimer(){
         yield return new WaitForSeconds(1.5f); // wait time
         //Starts Auto Timer After Time
         GoTimerStart();
         //Option for Main Screen Message Centre Message that Auto Device Timer Has Started
         //MessageCentreManager STM = FindObjectOfType<MessageCentreManager> ();
         //STM.GoAutoStartTimerMessage ();
     }

I have this on a toggle but when I turn on the toggle my timer naturally starts right away because it just sort of views it like a button press, which is fine if I had to live with it because all I would need to do is stop and reset the timer. I figure there is probably a better way to do it with something like:

When scene loads if the toggle "isOn" && level 01 has started then start the timer? It's funny in my head I can sort of see it just a little fuzzy on how to execute that ;)

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 ShadyProductions · Jan 26, 2016 at 03:50 PM -1
Share
 void OnLevelWasLoaded(int level) {
 if (level == 01 && isOn) {
 StartCoroutine(AutoStartTimer());
 }
 }

This method is called after a level is loaded.

avatar image KnightRiderGuy ShadyProductions · Jan 26, 2016 at 06:37 PM 0
Share

Thanks @ShadyProductions, yeah I knew about that but I was wondering if I would be able to call it in something like this sos that when I turn on my toggle that the timer would not just start right away ;) ?

 //Toggle for Auto Selected Times Timer 
     public void ToggleAutoStartTimer(){
         autoStartTimerToggleState = !autoStartTimerToggleState;
         DataHolder DH = FindObjectOfType<DataHolder> ();
         DH.autoStartTimerOnOff();
         if (autoStartTimerToggleState == true) {
             StartCoroutine (AutoStartTimer());
             //Option For $$anonymous$$ain Screen $$anonymous$$essage Centre $$anonymous$$essage
             //$$anonymous$$essageCentre$$anonymous$$anager AsTOn = FindObjectOfType<$$anonymous$$essageCentre$$anonymous$$anager> ();
             //AsTOn.GoAutoStartTimer$$anonymous$$essage ();
         } else {
             autoStartTimerToggleState = false;
             //Option For $$anonymous$$ain Screen $$anonymous$$essage Centre $$anonymous$$essage
             //$$anonymous$$essageCentre$$anonymous$$anager AsTOff = FindObjectOfType<$$anonymous$$essageCentre$$anonymous$$anager> ();
             //AsTOff.GoAutoStartTimerOff$$anonymous$$essage ();
         }
     }
 
 
     IEnumerator AutoStartTimer(){
         yield return new WaitForSeconds(1.5f); // wait time
         //Starts Auto Timer After Time
         GoTimerStart();
         //Option for $$anonymous$$ain Screen $$anonymous$$essage Centre $$anonymous$$essage that Auto Device Timer Has Started
         //$$anonymous$$essageCentre$$anonymous$$anager ST$$anonymous$$ = FindObjectOfType<$$anonymous$$essageCentre$$anonymous$$anager> ();
         //ST$$anonymous$$.GoAutoStartTimer$$anonymous$$essage ();
     }

0 Replies

· Add your reply
  • Sort: 

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

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

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

put a void in an if statement? 1 Answer

How Do I Turn Off Toggle in a ToggleGroup ? 1 Answer

UnityEngine.SceneManagement contains no methods? 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