| Main Menu |
|---|
| Games |
|---|
| Current Projects |
|---|
| Articles & Tutorials |
|---|
| Other works |
|---|
| Unity 3 - Mouse Input |
|
|
|
Reading mouse positionLet's see how to read the mouse current position in our Unity Game. An important thing to note is that, unlike where using Flash for example, in Unity the origin of the screen is at the bottom left
Now, to read the position of your mouse, you just need to read the Input.mousePosition static property of the Input class, which returns a Vector3.
and the output will be similar to this
Of course, since it is a Vector3, you can retrieve each component reading its x, y and z properties, for example
or
Hiding mouse pointerIn some cases, for example when using a First Person Controller, you may want to hide the mouse pointer. It is also necessary when you want to implement your custom mouse pointer. Doing it is really easy, you simply need to do this:
|




Comments
RSS feed for comments to this post