Version: 2022.2
言語: 日本語
public static void SetCursor (Texture2D texture, Vector2 hotspot, CursorMode cursorMode);

パラメーター

texture The texture to use for the cursor. To use a texture, 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 The offset from the top left of the texture to use as the target point. This must be in the bounds of the cursor.
cursorMode Whether to render this cursor as a hardware cursor on supported platforms, or force software cursor.

説明

Sets a custom cursor to use as your cursor.

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

using UnityEngine;

// Attach this script to a GameObject with a Collider, then mouse over the object to see your cursor change. 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() { // Pass 'null' to the texture parameter to use the default system cursor. Cursor.SetCursor(null, Vector2.zero, cursorMode); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961