Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 hiiii5 · Jul 15, 2015 at 08:47 PM · c#guiinstantiategamemouse

Ensuring Correct Call Order

Currently I am working on an RTS styled management game and am having some issues arising from unity's call order for it's built in methods.

Instead of putting actual source code as it would be too much and make the question unspecific I will outline the problem.

I am using a creation controller class that upon pressing a button, based in the GUI function of that class, will allow you to place a house. As soon as this button is pressed it will change a bool called placing from false to true. Then the house prefab will be instantiated, as it was passed into the script via the editor, and then this script will move onto the update function allowing mouse based placement.

Upon pressing the right mouse button, everything will be placed and freed up, the instance object will be added to a list of placed objects and then the house will be allowed to be clicked on by changing an internal bool for the house to true and setting the placing bool to false.

Then upon clicking the house, given that you aren't placing anything and the house can be clicked on, a menu will pop up from the house's GUI function.

The issue arises because OnGUI() is called after Update(), since I am changing the bool values in the Update function of the creation controller to ensure that everything is being read from the list I have created. Upon placing the object the menu will pop up immediately since the mouse is over it already.

While the bool values are supposed to change this, and I am checking them in the OnGUI function for the house, it does not seem to matter as the call order for OnGUI is stacked after Update so the bools have already changed.

My objective to to ensure that this does not happen, instead I want the menu to only be allowed to be opened after the initial mouse click.

Any suggestions on how I may achieve this?

Comment
Add comment · Show 1
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 hiiii5 · Jul 15, 2015 at 03:01 AM 1
Share

Currently my work around is to tie the placement to the left mouse button, and the house clicking to right mouse button. Still interested to see if this can be more elegant for the user.

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

2 People are following this question.

avatar image avatar image

Related Questions

Instantiate and Scale with Mouse Click. 1 Answer

How can I disable toggles when 2 toggles checked? 1 Answer

Overlapping GUI Button priority 3 Answers

Need help understanding GUI and Rect.Contains interaction 0 Answers

How to fire gui button on mouse right release 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