Search Unity

Trigger detection in GUI without mouse

Discussion in 'Immediate Mode GUI (IMGUI)' started by Michele, Jun 6, 2008.

  1. Michele

    Michele

    Joined:
    Apr 28, 2008
    Posts:
    73
    Hi everyone,
    I'm new in this great world of Unity. This is my problem, I hope someone could help me with some code or suggestions:

    - I have a menu (a GUI Button)
    - I have a GUI texture (newPointer) controlled with the wii_nunchuckstich
    - I want that when the newPointer trigger the GUI Button I receve a CallBack where I can put some code

    I've linked some screenshot to explain the scenario

    In the second image I should have the OnTrigger like function.

    I don't want to use the mouse to move the newPointer.
    Maybe there is a possibility to lock the mousePosition to the GUI Texture position?

    PS: The number and the position of the buttons could change, so I can't pass trough the position of the newPointer :(

    Thank you very much to everyone in advance.
     

    Attached Files:

  2. podperson

    podperson

    Joined:
    Jun 6, 2006
    Posts:
    1,371
    In essence you want to emulate a mouse with a Wii controller? Or you want to continue to use the mouse separately? Or you want to emulate the mouse but provide greater tolerance for error because of the controller's imprecision?

    I don't believe that you can set the mouse's position in Unity (except to lock it to the center of the screen using Screen.lockCursor=true) but if you could then you could simply force the mouse position to that of your virtual cursor and then create a custom GUIskin that made widgets bigger than they look (so they'd be easier to point at).

    The GUI stuff is all built around the mouse and is something of a black box. I think the API would need to be opened up a bit to allow people to manipulate it in the way you're describing (e.g. feed it a "faux" mouse position).

    I could be wrong though.

    Worst case, you can achieve the results you're after using the OLD GUITexture and GUIText components which give you complete control over the appearance and behavior of the screen elements. It's definitely not as easy and convenient as the GUI library, but it will work.
     
  3. Michele

    Michele

    Joined:
    Apr 28, 2008
    Posts:
    73
    Hi, thanks for the reply.
    Yes, my proposal is to emulate the mouse with the wii. I don't want to use the mouse separately. Just the wiimote + Nunchuck.
    This was my idea. But I have to think how to interact with the GUI in the scene.
    Have you other idea?

    I've read that the access to the GUI Layer with keyboard is not yet implemented :(

    Thanks