Table of Contents

Class DrawToolController

Main controller that wires all drawing tool components together. This is the primary entry point for the drawing tool. Uses DrawToolSettings ScriptableObject as single source of truth for all settings.

public class DrawToolController : MonoBehaviour
Inheritance
DrawToolController

Fields

OnBrushChanged

public UnityEvent OnBrushChanged

Field Value

UnityEvent

OnCanvasSaved

public UnityEvent<string> OnCanvasSaved

Field Value

UnityEvent<string>

OnDrawEnd

public UnityEvent OnDrawEnd

Field Value

UnityEvent

OnDrawStart

public UnityEvent OnDrawStart

Field Value

UnityEvent

OnImageImported

public UnityEvent<string> OnImageImported

Field Value

UnityEvent<string>

OnPrimaryColorChanged

public UnityEvent<Color> OnPrimaryColorChanged

Field Value

UnityEvent<Color>

OnSecondaryColorChanged

public UnityEvent<Color> OnSecondaryColorChanged

Field Value

UnityEvent<Color>

OnToolChanged

public UnityEvent<DrawToolSettings.DrawingTool> OnToolChanged

Field Value

UnityEvent<DrawingTool>

Properties

CanvasUI

public DrawCanvasUI CanvasUI { get; }

Property Value

DrawCanvasUI

ColorPicker

public ColorPickerUI ColorPicker { get; }

Property Value

ColorPickerUI

CurrentTool

public DrawToolSettings.DrawingTool CurrentTool { get; }

Property Value

DrawToolSettings.DrawingTool

DrawingEngine

public DrawingEngine DrawingEngine { get; }

Property Value

DrawingEngine

DrawingInput

public DrawingInput DrawingInput { get; }

Property Value

DrawingInput

ImageSelectionManager

public ImageSelectionManager ImageSelectionManager { get; }

Property Value

ImageSelectionManager

IsDrawing

public bool IsDrawing { get; }

Property Value

bool

LayerManager

public LayerManager LayerManager { get; }

Property Value

LayerManager

LayerPanel

public LayerPanelUI LayerPanel { get; }

Property Value

LayerPanelUI

PenInput

public PenInput PenInput { get; }

Property Value

PenInput

PrimaryColor

public Color PrimaryColor { get; }

Property Value

Color

SecondaryColor

public Color SecondaryColor { get; }

Property Value

Color

Settings

public DrawToolSettings Settings { get; }

Property Value

DrawToolSettings

Methods

ApplyBrushPreset(BrushPreset)

Apply a brush preset.

public void ApplyBrushPreset(DrawToolSettings.BrushPreset preset)

Parameters

preset DrawToolSettings.BrushPreset

ClearCanvas()

Clear the current canvas.

public void ClearCanvas()

ClearLayerSelection()

Clear current layer selection.

public void ClearLayerSelection()

ExportAsJPG(string, int)

Export the canvas as JPG.

public void ExportAsJPG(string filePath, int quality = 90)

Parameters

filePath string
quality int

ExportAsPNG(string)

Export the canvas as PNG.

public void ExportAsPNG(string filePath)

Parameters

filePath string

FitSelectedLayerToCanvas()

Fit selected layer to canvas bounds.

public void FitSelectedLayerToCanvas()

ImportImage(string)

Import an image to the active layer.

public void ImportImage(string filePath)

Parameters

filePath string

ImportImageAsTransformableLayer(string, string)

Import an image as a new layer that maintains aspect ratio and can be transformed. The image layer preserves its original size and can be moved/scaled/rotated.

public LayerObject ImportImageAsTransformableLayer(string filePath, string layerName = null)

Parameters

filePath string
layerName string

Returns

LayerObject

ImportImageAsTransformableLayer(Texture2D, string)

Import an image from a Texture2D as a transformable layer.

public LayerObject ImportImageAsTransformableLayer(Texture2D texture, string layerName = null)

Parameters

texture Texture2D
layerName string

Returns

LayerObject

ImportImageToNewLayer(string, string)

Import an image to a new layer.

public void ImportImageToNewLayer(string filePath, string layerName = null)

Parameters

filePath string
layerName string

Initialize()

Initialize the controller. Call this after wiring references at runtime.

public void Initialize()

NewCanvas(int, int, Color)

Create a new canvas.

public void NewCanvas(int width, int height, Color backgroundColor)

Parameters

width int
height int
backgroundColor Color

Redo()

Redo last undone operation (placeholder - not yet implemented).

public void Redo()

ResetSelectedLayerSize()

Reset selected layer to original size.

public void ResetSelectedLayerSize()

SelectLayerForTransform(LayerObject)

Select a layer for transform operations.

public void SelectLayerForTransform(LayerObject layer)

Parameters

layer LayerObject

SetBrushHardness(float)

Set brush hardness.

public void SetBrushHardness(float hardness)

Parameters

hardness float

SetBrushOpacity(float)

Set brush opacity.

public void SetBrushOpacity(float opacity)

Parameters

opacity float

SetBrushSize(int)

Set brush size.

public void SetBrushSize(int size)

Parameters

size int

SetBrushSpacing(float)

Set brush spacing.

public void SetBrushSpacing(float spacing)

Parameters

spacing float

SetBrushType(BrushType)

Set brush type.

public void SetBrushType(Brush.BrushType type)

Parameters

type Brush.BrushType

SetMaintainAspectRatio(bool)

Set whether imported images maintain aspect ratio when scaling.

public void SetMaintainAspectRatio(bool maintain)

Parameters

maintain bool

SetPrimaryColor(Color)

Set the primary drawing color.

public void SetPrimaryColor(Color color)

Parameters

color Color

SetSecondaryColor(Color)

Set the secondary drawing color.

public void SetSecondaryColor(Color color)

Parameters

color Color

SetTool(DrawingTool)

Set the current drawing tool.

public void SetTool(DrawToolSettings.DrawingTool tool)

Parameters

tool DrawToolSettings.DrawingTool

SwapColors()

Swap primary and secondary colors.

public void SwapColors()

Undo()

Undo last operation (placeholder - not yet implemented).

public void Undo()

ZoomToActualSize()

Zoom to actual size (100%).

public void ZoomToActualSize()

ZoomToFit()

Zoom to fit canvas in view.

public void ZoomToFit()