Class DrawingInput
- Namespace
- WitShells.CanvasDrawTool
Handles all input for the drawing tool using New Input System. Supports mouse, touch, and provides base for pen input.
public class DrawingInput : MonoBehaviour
- Inheritance
-
DrawingInput
- Derived
Fields
OnDrawEnd
public UnityEvent<Vector2, float> OnDrawEnd
Field Value
- UnityEvent<Vector2, float>
OnDrawMove
public UnityEvent<Vector2, float> OnDrawMove
Field Value
- UnityEvent<Vector2, float>
OnDrawStart
public UnityEvent<Vector2, float> OnDrawStart
Field Value
- UnityEvent<Vector2, float>
OnPan
public UnityEvent<Vector2> OnPan
Field Value
- UnityEvent<Vector2>
OnZoom
public UnityEvent<float> OnZoom
Field Value
- UnityEvent<float>
_currentPressure
protected float _currentPressure
Field Value
_isDrawing
protected bool _isDrawing
Field Value
_lastPosition
protected Vector2 _lastPosition
Field Value
- Vector2
Properties
CurrentPressure
public float CurrentPressure { get; }
Property Value
IsDrawing
public bool IsDrawing { get; }
Property Value
LastPosition
public Vector2 LastPosition { get; }
Property Value
- Vector2
Methods
Awake()
protected virtual void Awake()
ContinueDraw(Vector2, float)
protected virtual void ContinueDraw(Vector2 canvasPosition, float pressure)
Parameters
canvasPositionVector2pressurefloat
EndDraw(Vector2, float)
protected virtual void EndDraw(Vector2 canvasPosition, float pressure)
Parameters
canvasPositionVector2pressurefloat
GetTouchPressure(Finger)
protected virtual float GetTouchPressure(Finger finger)
Parameters
fingerFinger
Returns
NormalizedToPixel(Vector2, int, int)
Convert normalized canvas position to pixel coordinates.
public Vector2Int NormalizedToPixel(Vector2 normalized, int width, int height)
Parameters
Returns
- Vector2Int
OnDisable()
protected virtual void OnDisable()
OnEnable()
protected virtual void OnEnable()
ScreenToCanvas(Vector2, out Vector2)
Convert screen position to canvas coordinates. Returns normalized coordinates (0-1) relative to canvas bounds.
public bool ScreenToCanvas(Vector2 screenPosition, out Vector2 canvasPosition)
Parameters
screenPositionVector2canvasPositionVector2
Returns
SetCanvasRect(RectTransform)
Set the canvas rect transform for coordinate conversion.
public void SetCanvasRect(RectTransform rect)
Parameters
rectRectTransform
SetUICamera(Camera)
Set the UI camera for coordinate conversion.
public void SetUICamera(Camera cam)
Parameters
camCamera
StartDraw(Vector2, float)
protected virtual void StartDraw(Vector2 canvasPosition, float pressure)
Parameters
canvasPositionVector2pressurefloat
Update()
protected virtual void Update()