- Home /
Question by
yujinjjang · May 28, 2017 at 03:17 PM ·
textureschangeif-statementsmouse cursor
Mouse cursor texture change
I want the texture of the mouse cursor to change when I click the mouse.
public Texture2D cursorTexture;
public Texture2D cursorPointer;
public Texture2D Clickcursor;
public bool hotSpotIsCenter = false;
public Vector2 adjustHotSpot = Vector2.zero;
private Vector2 hotSpot;
public void Start(){
StartCoroutine ("MyCursor");
}
IEnumerator MyCursor() {
yield return new WaitForEndOfFrame();
if (hotSpotIsCenter) {
hotSpot.x = Clickcursor.width / 2;
hotSpot.y = Clickcursor.height / 2;
} else {
hotSpot = adjustHotSpot;
}
if (Input.GetMouseButton (0))
Cursor.SetCursor (Clickcursor, hotSpot, CursorMode.Auto);
else
Cursor.SetCursor (cursorTexture, hotSpot, CursorMode.Auto);
}
}
How do I modify the if statement?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612122836im_/https://answers.unity.com/themes/thub/images/avi.jpg)