Version: 2022.2
言語: 日本語
public static PenData GetPenEvent (int index);

戻り値

PenData Pen event details in the struct.

説明

Returns the PenData for the pen event at the given index in the pen event queue.

On Windows, the pen event queue holds, in chronological order, any missed pen events as provided by GetPointerPenInfoHistory. The queue is cleared at the end of each frame. On all other platforms the queue will always be empty.

using UnityEditor;
using UnityEngine;

public class Example : EditorWindow { [MenuItem("Window/Pen Window")] public static void ShowWindow() { EditorWindow win = EditorWindow.GetWindow(typeof(Example)); win.titleContent = new GUIContent("Pen Window"); win.wantsMouseMove = true; }

void OnGUI() { var e = Event.current; if ((e.type == EventType.MouseDown || e.type == EventType.MouseDrag || e.type == EventType.MouseDown || e.type == EventType.MouseUp || e.type == EventType.MouseMove) &amp;&amp; (e.pointerType == PointerType.Pen)) { int count = Input.penEventCount; for (int i = 0; i < count; i++) { // Log data from queued pen events PenData p = Input.GetPenEvent(i); Debug.Log($"Pen position {p.position}, pen pressure {p.pressure}, pen twist {p.twist}, pen tilt {p.tilt}, pen status - barrel {(p.penStatus &amp; PenStatus.Barrel) != 0}"); } Input.ResetPenEvents(); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961