Table of Contents

Class PenInput

Specialized input handler for pen/stylus tablets. Supports pressure sensitivity, tilt, and pen-specific features. Works with Wacom, Surface Pen, Apple Pencil (via Unity's Pen device).

public class PenInput : DrawingInput
Inheritance
PenInput
Inherited Members

Fields

OnBarrelButtonPressed

public UnityEvent OnBarrelButtonPressed

Field Value

UnityEvent

OnBarrelButtonReleased

public UnityEvent OnBarrelButtonReleased

Field Value

UnityEvent

OnEraserTipActive

public UnityEvent OnEraserTipActive

Field Value

UnityEvent

OnPenTipActive

public UnityEvent OnPenTipActive

Field Value

UnityEvent

OnPressureChanged

public UnityEvent<float> OnPressureChanged

Field Value

UnityEvent<float>

OnTiltChanged

public UnityEvent<Vector2> OnTiltChanged

Field Value

UnityEvent<Vector2>

Properties

CurrentBarrelAction

public PenInput.BarrelButtonAction CurrentBarrelAction { get; }

Property Value

PenInput.BarrelButtonAction

IsBarrelButtonPressed

public bool IsBarrelButtonPressed { get; }

Property Value

bool

IsEraserTip

public bool IsEraserTip { get; }

Property Value

bool

IsPenAvailable

public bool IsPenAvailable { get; }

Property Value

bool

RawPressure

public float RawPressure { get; }

Property Value

float

Tilt

public Vector2 Tilt { get; }

Property Value

Vector2

UsePressureForOpacity

public bool UsePressureForOpacity { get; set; }

Property Value

bool

UsePressureForSize

public bool UsePressureForSize { get; set; }

Property Value

bool

Methods

Awake()

protected override void Awake()

GetEffectiveOpacity(float, float)

Get the effective opacity based on pressure settings.

public float GetEffectiveOpacity(float baseOpacity, float pressure)

Parameters

baseOpacity float
pressure float

Returns

float

GetEffectiveSize(int, float)

Get the effective size based on pressure settings.

public int GetEffectiveSize(int baseSize, float pressure)

Parameters

baseSize int
pressure float

Returns

int

GetTouchPressure(Finger)

protected override float GetTouchPressure(UnityEngine.InputSystem.EnhancedTouch.Finger finger)

Parameters

finger Finger

Returns

float

SetBarrelButtonAction(BarrelButtonAction)

Set the barrel button action.

public void SetBarrelButtonAction(PenInput.BarrelButtonAction action)

Parameters

action PenInput.BarrelButtonAction

SetPressureCurve(AnimationCurve)

Set the pressure curve.

public void SetPressureCurve(AnimationCurve curve)

Parameters

curve AnimationCurve

ShouldUseEraser()

Check if we should use eraser (either eraser tip or barrel button set to eraser).

public bool ShouldUseEraser()

Returns

bool

ShouldUseEyedropper()

Check if we should use eyedropper (barrel button set to eyedropper).

public bool ShouldUseEyedropper()

Returns

bool

Update()

protected override void Update()