// /****************************************************************************** // * File: DrawingManager.cs // * Copyright (c) 2023 Qualcomm Technologies, Inc. and/or its subsidiaries. All rights reserved. // * // * // ******************************************************************************/ using UnityEngine; namespace QCHT.Samples.Drawing { public class DrawingManager : MonoBehaviour { public Pen Pen; #region Singleton private static DrawingManager s_instance; public static DrawingManager Instance { get { if (s_instance == null) s_instance = FindObjectOfType(); return s_instance; } } #endregion /// /// Sets the new brush descriptor to the current pen tool. /// /// The new brush descriptor. public void ChangeBrush(BrushDescriptor brush) { if (!Pen) return; Pen.SetBrush(brush); } /// /// Sets the new width to the current pen tool. /// /// The new width. public void SetWidth(float width) { if (!Pen) return; Pen.SetWidth(width); } /// /// Sets the current drawing mode. /// Converts integer to drawing. /// public void SetDrawingMode(Pen.DrawingMode drawingMode) { if (!Pen) return; Pen.SetDrawingMode(drawingMode); } /// /// Undo the current pen line. /// public void Undo() { if (!Pen) return; Pen.Undo(); } /// /// Redo the last removed pen line. /// public void Redo() { if (!Pen) return; Pen.Redo(); } /// /// Clears all lines done with this pen. /// public void Clear() { if (!Pen) return; Pen.Clear(); } } }