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 Noxury · Aug 20, 2015 at 08:52 PM · buttonmenusimulationretry

Application.Load() issue

Hey guys,

Now that no one can answer right my alternative question on how to simulate a button press I wanted to exactly call a function that changes some values in order to skip the start menu and to get to the actual game (retry-button).

My game consists of only 1 scene. When the game starts, the user sees a game menu.

On this is a play button which starts the arcade game itself. If the player lose, a retry and menu button will appear,

  • the menu button just reloads the whole scene since the scene starts with it. (done)

  • The retry button however needs to restart the scene and simulate the play button press which triggers the starting of the arcade game automatically.

For that the player needs to turn interactable and the menu should change from "Menu" (start menu) to "Game" (arcade game) as written in the OnRetrySinglePlayer()-function above.

I have a function that restarts my game and should skip the start menu like this:

 function OnRetrySinglePlayer(){
     Application.LoadLevel(0);
     var cv = GameObject.Find("Canvas").gameObject;
     var game = cv.transform.FindChild("Game").GetComponent.<_Menu>() as _Menu;
     var player = GameObject.Find("Player").gameObject;

     cv.GetComponent.<MenuManager>().ShowMenu(game);
     player.transform.GetComponent.<Player>().Interactable();
     //b_play.transform.GetComponent.<UI.Button>().onClick.AddListener(0); //old way to call the onClick function in the button-component
 }

This restarts only the scene with no errors.

I think the script itself reloads on Application.LoadLevel(0), so it never reaches further code.

Thanks in advance.

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

Answer by YoungDeveloper · Aug 20, 2015 at 09:19 PM

You changed the level, as script comes from other scene so of course reference is not linked. All what you have to do is find the reference.

You didn't really specify what happens on level load, what scripts are reloaded, are there any tagged with dontdestroyonload, is it the same level and so on. Who is Player, does it has something to do with question, if not why its mentioned? No wonder none answered your previous question.

Edit your question with required information.

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

26 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

Related Questions

Load, Save and Options Gui Help 1 Answer

Switching camera angles doesn't work, sticks on one menu. 0 Answers

Please Help !, camera rotation 1 Answer

How do you make a Main Menu that only takes Joystick input and is not affected by the Cursor 2 Answers

How can i create a popup menu when a button is clicked? 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