Class DrawToolController
- Namespace
- WitShells.CanvasDrawTool
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
ColorPicker
public ColorPickerUI ColorPicker { get; }
Property Value
CurrentTool
public DrawToolSettings.DrawingTool CurrentTool { get; }
Property Value
DrawingEngine
public DrawingEngine DrawingEngine { get; }
Property Value
DrawingInput
public DrawingInput DrawingInput { get; }
Property Value
ImageSelectionManager
public ImageSelectionManager ImageSelectionManager { get; }
Property Value
IsDrawing
public bool IsDrawing { get; }
Property Value
LayerManager
public LayerManager LayerManager { get; }
Property Value
LayerPanel
public LayerPanelUI LayerPanel { get; }
Property Value
PenInput
public PenInput PenInput { get; }
Property Value
PrimaryColor
public Color PrimaryColor { get; }
Property Value
- Color
SecondaryColor
public Color SecondaryColor { get; }
Property Value
- Color
Settings
public DrawToolSettings Settings { get; }
Property Value
Methods
ApplyBrushPreset(BrushPreset)
Apply a brush preset.
public void ApplyBrushPreset(DrawToolSettings.BrushPreset preset)
Parameters
presetDrawToolSettings.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
ExportAsPNG(string)
Export the canvas as PNG.
public void ExportAsPNG(string filePath)
Parameters
filePathstring
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
filePathstring
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
Returns
ImportImageAsTransformableLayer(Texture2D, string)
Import an image from a Texture2D as a transformable layer.
public LayerObject ImportImageAsTransformableLayer(Texture2D texture, string layerName = null)
Parameters
textureTexture2DlayerNamestring
Returns
ImportImageToNewLayer(string, string)
Import an image to a new layer.
public void ImportImageToNewLayer(string filePath, string layerName = null)
Parameters
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
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
layerLayerObject
SetBrushHardness(float)
Set brush hardness.
public void SetBrushHardness(float hardness)
Parameters
hardnessfloat
SetBrushOpacity(float)
Set brush opacity.
public void SetBrushOpacity(float opacity)
Parameters
opacityfloat
SetBrushSize(int)
Set brush size.
public void SetBrushSize(int size)
Parameters
sizeint
SetBrushSpacing(float)
Set brush spacing.
public void SetBrushSpacing(float spacing)
Parameters
spacingfloat
SetBrushType(BrushType)
Set brush type.
public void SetBrushType(Brush.BrushType type)
Parameters
SetMaintainAspectRatio(bool)
Set whether imported images maintain aspect ratio when scaling.
public void SetMaintainAspectRatio(bool maintain)
Parameters
maintainbool
SetPrimaryColor(Color)
Set the primary drawing color.
public void SetPrimaryColor(Color color)
Parameters
colorColor
SetSecondaryColor(Color)
Set the secondary drawing color.
public void SetSecondaryColor(Color color)
Parameters
colorColor
SetTool(DrawingTool)
Set the current drawing tool.
public void SetTool(DrawToolSettings.DrawingTool tool)
Parameters
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()