Version: 2023.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(); } } }