Version: 2021.3
言語: 日本語

Cursor.SetCursor(Texture2D,CursorMode)

マニュアルに切り替える

説明

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);

パラメーター

texture The texture to use for the cursor. To use a texture, you must first import it with `Read/Write`enabled. Alternatively, you can use the default cursor import setting. If you created your cursor texture from code, it must be in RGBA32 format, have alphaIsTransparency enabled, and have no mip chain. To use the default cursor, set the texture to `Null`.
hotspot ターゲット地点として使用するテクスチャの左上からのオフセット距離(カーソルの境界範囲にある必要があります)
cursorMode プラットフォームがサポートしているハードウェアのカーソルを使用するか、強制的にソフトウェアのカーソルを使用するかの設定

説明

使用したいカーソル画像を自由に設定できるカスタムカーソルです

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