Search Unity

function OnGUI with Input.GetMouse the right?

Discussion in 'Immediate Mode GUI (IMGUI)' started by StartGma, Nov 19, 2014.

  1. StartGma

    StartGma

    Joined:
    Oct 14, 2014
    Posts:
    14
    Hello I was wondering if you could put together a function GUI with the click of the mouse.
    I tried to do that after clicking on an object appear a window with a button ( the idea of the window with the button is it would be a type of speech where when click the button change speech). I tried to make a code to see if it worked but seems to not work

    Below the scrippt that I made

    I wonder if it would be possible to do this? If you can explain with an example?
    Code (JavaScript):
    1.  #pragma strict
    2.  
    3. var Person: GameObject;
    4.  
    5.  
    6. funcionar OnGUI () {
    7.  
    8. if (Input.GetMouseButtonDown == persona) {
    9.  
    10. var windowRect: Rect = Rect (70,70,180,70);
    11.  
    12. windowRect = GUI.Window (0, windowRect, WindowFunction, "My Window");
    13. }
    14.  
    15.     }
    16.  
    17. função WindowFunction (WindowID: int) {
    18.  
    19.     if (GUI.Button (Rect (20,20,70,25), "Button")) {
    20.      
    21. }
    22.         }
     
    Last edited: Nov 20, 2014
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You generally wouldn't want to use Input functions in OnGUI. Use Event.current instead, such as Event.current.type == EventType.MouseDown.

    --Eric
     
  3. StartGma

    StartGma

    Joined:
    Oct 14, 2014
    Posts:
    14
    I don't understand but I tried the script, nut if seems that the function does not perform.
    Could you aleborate? type with an example to see how the function works