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 /
avatar image
1
Question by Smoke_91 · Dec 15, 2012 at 01:18 AM · objectmousemenuclick

Object menu must be at the center of the object

I am creating a game with isometric camera. When i click on a object, i must open a menu localized at the center of the object, or at the center of the location where i click For example, now if i click on the bottom of the cilinder: (Now i use: `viewPosition = Camera.main.ScreenToViewportPoint(Input.mousePosition);` to set x and y cordinates of the menu) alt text

I want that A, B menu appear at the center of the cilinder or where i click!

error.jpg (36.1 kB)
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
2
Best Answer

Answer by Sixakoo_ · Dec 15, 2012 at 03:18 AM

Hello,

This is how to make the button appear when you click the object, put the script on the object you want to be clicked: -

 var showMenu : boolean;
 var mousePosition : Vector2;
 var mouseX : int;
 var mouseY : int;
 
 function OnMouseUp(){
     mouseX=Input.mousePosition.x;
     mouseY=Screen.height-Input.mousePosition.y;
     showMenu=!showMenu;
 }
 
 function OnGUI(){
     if(showMenu==true){
         if(GUI.Button(Rect(mouseX,mouseY,100,20),"a")){
         
         }
         if(GUI.Button(Rect(mouseX,mouseY+30,100,20),"b")){
         
         }
     }
 }

Hope this helps!

Comment
Add comment · Show 10 · 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 clunk47 · Dec 15, 2012 at 05:16 AM 0
Share

This is what I would say lol.

avatar image Smoke_91 · Dec 15, 2012 at 09:49 AM 0
Share

Sixakoo_ no it doesn't work.. The menu doesn't appear!

avatar image RobbingDaHood · Dec 15, 2012 at 11:23 AM 0
Share

Did you remember to set the show$$anonymous$$enu boolean to true?

avatar image Smoke_91 · Dec 15, 2012 at 01:05 PM 0
Share

yes... maybe is a camera problem..

avatar image Sixakoo_ · Dec 15, 2012 at 01:54 PM 0
Share

I already test this out and no problem. Have you attached the script to the object yet? $$anonymous$$ake sure it's the object you want to make the menu appear and has a collider so the mouse can interact with it.

Show more comments

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

12 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

Related Questions

Destroy objects by clicking on them 1 Answer

Object Movement via Mouse Click? 3 Answers

OnMouseUp() Click Display Effect. 1 Answer

Destroy object using mouse click(raycast to detect collision) 2 Answers

Mouse Click and Spawn object 4 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