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
0
Question by castor · Sep 10, 2012 at 03:09 AM · guimousemenuonmouseover

Loading GUI in middle of mouse and make it work radial

I'm doing a top down game and the idea is that when a player clicks and holds on a object it will present a radial GUI around where the mouse pointer is and the player can choose the options from it (point and click style).

THe way for choosing the options is similar to Maya radial menu where you click and hold, then drag the mouse to the option you want and lift it.

I managed to get the GUI to show where the mouse is when clicking on the object but its always aligned to the top left corner.

Also I have no idea how to disable the mouse from controlling the camera and getting it to control the new UI (and stop the UI from following the mouse for a few secs so you can choose the option).

Here is an example of what I mean as a radial menu: http://www.youtube.com/watch?v=edp_ZCzBG08&feature=player_detailpage#t=237s

Comment
Add comment · Show 4
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 castor · Sep 10, 2012 at 11:37 AM 0
Share

Just an update. I've been trying all day to do this and managed to learn quit a bit more about Unity. Using the UnityGUI I'm able to have the UI show where the mouse clicks and stay there when the character moves. I've also managed to create actions for the buttons.

The only issue now is that I can't find a On$$anonymous$$ouseUp control for the GUI. The idea is that the player presses and holds the L$$anonymous$$B to see the radial menu and then drags the mouse (while still holding) over the button he wants to activate.

The problem I have is that the current UI doesn't detect just releasing the mouse from hold as a button press...

avatar image lodendsg · Sep 10, 2012 at 12:19 PM 0
Share

Could you use input.Get$$anonymous$$ouseButtonUp(0) on an UpDate() and do what you need from there?

avatar image Bunny83 · Sep 10, 2012 at 01:26 PM 0
Share

@lodendsg: You shouldn't mix the Input class with GUI stuff ;) OnGUI has it's own event management.

It's fine to use Input.Get$$anonymous$$ouseButtonDown in Update to set a boolean which will display the GUI, but interactions with GUI elements should be handled in OnGUI itself.

avatar image NeoWatchowsky · May 25, 2014 at 05:17 PM 0
Share

Hello! I have installed a Pie$$anonymous$$enu component and customized the style of it. But I have problem with the action of the buttons. There are 3 buttons by the menu. When I click one of the buttons the project runs this script:

 using UnityEngine;
 using System.Collections;
 
 public class $$anonymous$$enuItemActions_3 : $$anonymous$$onoBehaviour {
     void OnSelect(string command) {
         Debug.Log("A Left $$anonymous$$enu Command Received: " + command);    
     }
 } 

The piemenu object has a setting for commands. The string data is One Two and Three as default. How can I change these datas to open each button a GUI texture separately? alt text

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Bunny83 · Sep 10, 2012 at 01:24 PM

When someone talks about a radial menu i always think of the old second life pie menu or L4D voice menu. I never used Maya ( since i'm a programmer :) ), but the menu seems to look way differently than i would imagine a radial menu. Well, it doesn't actually matter :D but a screenshot of your menu would be a better reference since we can also see what's the problem.

Ok, now to your menu. The UnityGUI elements are ment as usual gui controls. So a click on a button is only counted when you click down and release on the same button. That's the normal GUI behaviour in almost all GUIs. In your case you have to test the releases yourself. You could write your own "GUI control"-function (like Button()) but only react to mouse up and ignores the mouse down event.

 // C#
 
 bool ReleaseArea(Rect aRect, GUIContent aContent, GUIStyle aStyle)
 {
     Event e = Event.current;
     bool isOver = aRect.Contains(e.mousePosition);
     if (e.type == EventType.Repaint)
         aStyle.Draw(aRect,aContent, isOver, true, true, false);
     else if (isOver && e.type == EventType.MouseUp)
         return true;
     return false;
 }
 
 
 void OnGUI()
 {
     if (ReleaseArea(new Rect(10,10,200,50), new GUIContent("Button1"), "Button"))
     {
         // mouse was released on this area
     }
 }

Comment
Add comment · Show 2 · 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 castor · Sep 14, 2012 at 07:25 PM 0
Share

Thanks for the help! Would it be possible to show the answer in javascript too?

avatar image ThermalFusion · Sep 14, 2012 at 07:38 PM 1
Share

just change the order of things and you have js (don't forget to add var in front of declarations like i did :)

 Event e = Event.current;  // C#
 var e : Event = Event.current; // js

 bool ReleaseArea(Rect aRect, GUIContent aContent, GUIStyle aStyle) // C#
 function ReleaseArea(var aRect : Rect , var aContent : GUIContent , var aStyle : GUIStyle ) : bool // js

http://wiki.unity3d.com/index.php/Csharp_Differences_from_JS

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

FPC Mouselook Axis problem on pause GUI 1 Answer

menu issue and mouse click 0 Answers

Gui Menu - Help Please. 2 Answers

changing from mouse click to keys 0 Answers

GUI not work after building 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