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 /
  • Help Room /
avatar image
0
Question by taifun4744 · Nov 07, 2015 at 12:59 AM · uimousepanel

Open UI Panel on Mouse Position

Good Evening

Can someone please give me a Tip on how to do that? I tried Input.mousePosition but the Panel follows the mouse, I want it to stay at its Position. I just cant get it to work.

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

4 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Dibbie · Nov 07, 2015 at 01:38 AM

You could try adding a EventTrigger to your object, and using the Mouse Over/Pointer Enter attribute, then attach a script to that attribute that will show your panel.

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
avatar image
0

Answer by taifun4744 · Nov 07, 2015 at 10:26 AM

Good morning

Thank you Dibbie. Hmm but that is not quite what I want. I want it to Show always on Mouse Position and stay. Like a Rightclick Menu. It Shows up when you Rightclick on the Canvas and stays.

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
avatar image
0

Answer by OctoMan · Nov 07, 2015 at 10:57 AM

So you just want to show a panel where it is when you mouse over a button?

You can use A Raycast or OnMouseOver().

Once you are over that button, just set the panel to active

 public GameObject PanelToShow;
 
 void OnMouseOver()
 {
 PanelToShow.SetActive(true);
 }
 else
 {
 PanelToShow.SetActive(false);
 }


[1]: http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnMouseOver.html

Comment
Add comment · Show 4 · 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 taifun4744 · Nov 07, 2015 at 11:14 AM 0
Share

Good $$anonymous$$orning

No, Im Sorry. I just cant get you to Understand. I have a GameObject Panel, and I have shortcut $$anonymous$$ey for that Panel. If i press that shortcut, the Panel Shows up. Now I want it to Show where the mouse is. If I use this script below, i get it to Show on mouse Position but it follows the mouse. And I dont want that.

     public GameObject Panel;
     private bool ShowPanel;
     
     void Start(){
         Panel.SetActive (false);
     }
     
     void Update(){
         if (Input.Get$$anonymous$$eyUp ($$anonymous$$eyCode.A)){
             ShowPanel =!ShowPanel;
             Panel.SetActive(ShowPanel);
         }
 
         Panel.transform.position = Input.mousePosition;
     }
avatar image OctoMan taifun4744 · Nov 07, 2015 at 11:18 AM 1
Share

Just take

 Panel.transform.position = Input.mousePosition;

out of Update anyhow. Otherwise it will stay at mouseposition.

Edit: Corrected my answer. Sorry

 void Update(){
          if (Input.Get$$anonymous$$eyUp ($$anonymous$$eyCode.A)){
              ShowPanel =!ShowPanel;
              Panel.SetActive(ShowPanel);
              showpanel = true;
          }
          if (showpanel && ShowPanel)
          {
          Panel.transform.position = Input.mousePosition;
          showpanel = false;
          }
      }

$$anonymous$$aybe this works.

avatar image taifun4744 OctoMan · Nov 07, 2015 at 12:25 PM 0
Share

Hi

Thank you Octo$$anonymous$$an. I got it to work. Herzlichen Dank.

     public GameObject Panel;
     private bool ShowPanel;
     
     void Start(){
         Panel.SetActive (false);
     }
     
     void Update(){
         if (Input.Get$$anonymous$$eyUp ($$anonymous$$eyCode.A)){
             ShowPanel =!ShowPanel;
             Panel.SetActive(ShowPanel);
             
             if (Panel && Panel) {
                 Panel.transform.position = Input.mousePosition;
             }
         }
     }
 }
 
Show more comments
avatar image
0

Answer by noumankhan00 · Oct 25, 2018 at 08:10 AM

hy,WITH which object i attach this script camera or panel ?

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

[SOLVED] Image is not visible in Panel (in game view) 0 Answers

How do I use anchors in UI? 0 Answers

Panel with Values From Array 1 Answer

Dynamic width panel 1 Answer

How do I detect if my mouse is over UI? 0 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