- Home /
Selection box not working
Hi, I have this code that should make a selection box, but it doesn't work. btnDown dosn't get read by the code.
here is my code:
var Xpos : float; var Ypos : float;
function OnGUI() { var btnDown : boolean = Input.GetButtonDown("Fire3"); var btn : boolean = Input.GetButton("Fire2"); if(btnDown) { Xpos = Event.current.mousePosition.x; Ypos = Event.current.mousePosition.y; } if(btn) { GUI.Box(Rect(Xpos, Ypos, Xpos+Event.current.mousePosition.x, -Ypos+Event.current.mousePosition.y), ""); } }
I tried your code, it is actually creating the box. Whats the problem? Are you triying to select the objects in scene?
No, I want to set the box to where the mouse starts. Edit, the btnDown var should be Fire2.
However, when looking into selecting objects, I realized that it would probably be a big project. Any help on that would be helpful!!! :)
Your answer
Follow this Question
Related Questions
Drawing a GUI box by specifying the two corners 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
C# converting Input.Mouseposition.y to to "top" argument of GUI.Box 1 Answer
Applying a script to multiple gui boxes 0 Answers
Setting Scroll View Width GUILayout 1 Answer