The original version, the API can be directly set mouse display or not, the new version is changed, first up and down the old shop version;
1. Ideas:
- In some games, the mouse is often hidden, or there are brilliant animations in place of the mouse display.
- The principle is to hide the mouse (not display) up, set a sprite coordinates for the mouse coordinates. Of course the code should be put in the update.
- Note: This script cannot be hung on the camera, otherwise there will be a mouse flicker situation.
Incidentally, attach a previous script:
Instance code:
Public Dfguicamera Camera; Public Dfslicedsprite Sprite; Public float value = 0f; void Update () {// Hide Mouse false= Camera.camera.ScreenToWorldPoint ( New Vector3 (INPUT.MOUSEPOSITION.X,INPUT.MOUSEPOSITION.Y,INPUT.MOUSEPOSITION.Z));}
2. First, to do the mouse personalized pictures, format if the cursor; see:
The second step: script mount, write the script, the default and click on the mouse image, drag and drop in it;
Publictexture2d NorT; Publictexture2d presst; PrivateVector2 hotspot; voidStart () {//screen.showcursor = false;//outofdate//cursor.setcursor (NorT, hotspot, Cursormode.auto); } Private voidUpdate () {if(Input.getmousebutton (0) {cursor.setcursor (presst, Vector2.zero, Cursormode.auto); //cursor.setcursor (Presst, Hospot, Cursormode.auto); //hotspot:the offset from the top left of the texture to use as the target point (must//Be within the bounds of the cursor). Default Selection Vector2.zero//the offset from the top of the texture as the target point (you must//In the range of the cursor) } Else{cursor.setcursor (NorT, Vector2.zero, Cursormode.auto); } }
Simply put, the above method to achieve the left mouse button click on the mouse will be set to the image of the corresponding picture.
In the code cursormode = Cursormode.forcesoftware; This mode means that when the mouse changes, the mouse moves outside the Unity window (for example, if you open a different software) the mouse in unity will still not disappear and is a set icon.
If Cursormode = Cursormode.auto This mode, there is only one mouse style, and when you move to the Unity window, there is no mouse in unity.
Unity Mouse Personalization