Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by pekrewrek · Feb 21, 2014 at 04:48 PM · guimenustatestate-machinegame-state-management

In-game menu screens

Hello, everyone.

Making a small game I got to the point where I want to add menus to my game. I came to conclusion that the main menu should be made in a separate scene and in-game menus - in the gaming scene with the help of Unity.GUI.

The problem here is I don't know how to make GUI work alongside the scripts for my GameObjects. Let's say during the game I move my player/cursor/whatever with gamepad's analog stick. When I hit some very special button - the menu shows up. This menu should be controlled with the same analog stick of the same controller. So I'll have two objects receive input and react to it at the same time, which is not desirable.

For now I have made almost all my scripts inherit from PausableMonoBehaviour which itself inherits a MonoBehaviour and can be paused/unpaused and reacts to it like this:

 void Update()
 {
     if(IsPaused)
     {
         return;
     }

     // do the input and other stuff here
 }

This one works OK but I wonder if there are better solutions? I thought of FSM's, but can't seem to pack it all up with the component-based programming model.

P.S. By OK I mean for now - while I don't have a lot of objects in my game. Because with all this objects around I have to use FindObjectsOfType() (which is not very fast I believe) and then iterate all found objects to pause them. And then comes UNPAUSE with the same logic! So it seems that this solution is far from perfect.

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
Best Answer

Answer by whydoidoit · Feb 21, 2014 at 04:59 PM

So it sounds like IsPaused should be a static so you can set it and not have to find any objects.

Comment
Add comment · Show 1 · 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 pekrewrek · Feb 22, 2014 at 10:33 AM 0
Share

Guess that should work. Especially since there's only one thread. Thanks.

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

19 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

Related Questions

How do I make a stylish GUI? 0 Answers

What's the difference between Normal and OnNormal in GUIStyle 2 Answers

How to place/add a HD image/picture in background of my game? 0 Answers

Display material options menu on click 0 Answers

GUI Menu Major Performance Issues 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