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 /
  • Help Room /
avatar image
0
Question by bathorsthroat · Feb 05, 2016 at 01:42 PM · error messageapplication.loadlevelgameover

How to change level after my game over screen appears? C#

Hello, I am creating game with use of a master script. Inside my Game Over Script I would like for the first level to be loaded Blank number of seconds after the Game Over Panel is set to true. When I try this my "void TurnOnGameOverPanel()" gives and error "cannot be an iterator block because `void' is not an iterator interface type". Can anyone help me out on this one? Thanks

P.S. I know my script is correct but it's my best shot at it and I'd stuck. It's in C# by the way. :)

  public class GameManager_Frank_GameOver : MonoBehaviour
     {
         private GameManager_Frank_Master gameManagerMaster;
         private Player_Master playerMaster;
         public GameObject panelGameOver;
 
 
         void OnEnable()
 
         {
             SetInitalReferecnes();
             {
 
                 gameManagerMaster.GameOverEvent += TurnOnGameOverPanel;
 
             }
 
         }
 
         void OnDisable()
 
         {
             gameManagerMaster.GameOverEvent -= TurnOnGameOverPanel;
 
         }
 
         void SetInitalReferecnes()
         {
             gameManagerMaster = GetComponent<GameManager_Frank_Master>();
         } 
 
         void TurnOnGameOverPanel()
 
         {
             if (panelGameOver != null)
             {
 
                 panelGameOver.SetActive(true);
                 yield return new WaitForSeconds(6);
                 Application.LoadLevel(1);
             }
         }
 
     }
 }
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
1
Best Answer

Answer by maxartz15 · Feb 16, 2016 at 06:09 PM

you have to use a IEnumerator for waitforseconds:

      IEnumerator TurnOnGameOverPanel()
     {
     if (panelGameOver != null)
              {
  
                  panelGameOver.SetActive(true);
                  yield return new WaitForSeconds(6);
                  Application.LoadLevel(1);
              }
     }

And you have to start it:

 StartCoroutine(TurnOnGameOverPanel());

Link info: http://docs.unity3d.com/ScriptReference/Coroutine.html http://docs.unity3d.com/Manual/30_search.html?q=IEnumerator

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

40 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

Related Questions

Unityengine does not exist in the current context. 0 Answers

The referenced script on this Behaviour is missing! (One solution to this problem) 0 Answers

The type or namespace name `WSA' does not exist in the namespace `UnityEngine.VR'. Are you missing an assembly reference? 0 Answers

What i can do with Type Load Exception Unity3d 0 Answers

c# Unreachable code detected 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