• 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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



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

Game over menu 0 Answers

Application.LoadLevel problem 0 Answers

Error CS8025 What can i do ? 0 Answers

Problem with Social.ReportScore 1 Answer

Assets/Scripts/Quit Menu Script.cs(24,22): error CS1525: Unexpected symbol `public'. Please Help as I am A NOOOOOOB in programming! 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges