Version: 2017.1

Cursor.SetCursor(Texture2D,CursorMode)

Switch to Manual

Description

Sets the mouse cursor to the given texture.

Call this method with a Texture2D to change the appearance of the hardware pointer (mouse cursor).

The cursorMode parameter allows you to use hardware cursors on supported platforms, or force software rendering of the cursor.

In the following example, the mouse cursor is changed to a given texture when OnMouseEnter is called, and reset to default when OnMouseExit is called.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Texture2D cursorTexture; public CursorMode cursorMode = CursorMode.Auto; public Vector2 hotSpot = Vector2.zero; void OnMouseEnter() { Cursor.SetCursor(cursorTexture, hotSpot, cursorMode); }

void OnMouseExit() { Cursor.SetCursor(null, Vector2.zero, cursorMode); } }

public static void SetCursor (Texture2D texture, Vector2 hotspot, CursorMode cursorMode);

Parameters

texture The texture to use for the cursor or null to set the default cursor. Note that a texture needs to be imported with "Read/Write enabled" in the texture importer (or using the "Cursor" defaults), in order to be used as a cursor.
hotspot @param hotspot Сдвиг относительно верхнего левого угла текстуры для использования в качестве точки клика (сдвиг должен быть внутри границ курсора).
cursorMode @param cursorMode Позволяет на поддерживающих платформах рендерить курсор как аппаратный, или принудительно рендерить курсор как программный.

Description

Задает пользовательский курсор, который будет использоваться.

Call this method with a Texture2D to change the appearance of the hardware pointer (mouse cursor).