Project Template
This is a project template of a Pixel Art drawing app made in Unity 6 using UI toolkit. You will get access to all the CODE, Art and other assets in a form of an editable Unity Project. Use it for your games or apps commercially or otherwise. All the code is commented.
My Tutorial about this mechanic:
Project Overview:
- Unity Version: Unity 6 (6000.0.23f1)
- UI Framework: UI Toolki
-
Design Philosophy: Modular and easily reusable
Key Features
- Modular Architecture: The UI is separate from the drawing system, allowing easy reuse for 2D, 3D, or UI-based projects.
- Advanced Color Selection:
- Color selection square
- HSV (Hue, Saturation, Value) sliders
- Alpha slider for transparency
- Direct value input for precise color selection
- Drawing Tools:
- Pen
- Eraser
- Line drawer
- Square drawer
- Color picker
- Adjustable Brush Size: Affects all drawing tools
- Drawing preview: Each tool shows preview of how it will affect the canvas
- Canvas Display: Uses RenderTexture to separate UI from drawing code
- Save Functionality: Exports drawings as PNG files
- Documentation: Comments in the code
Technical Implementation
- The project structure follows object-oriented design principles for easy expansion and modification. For example we have a "DrawingTool" abstract class so that we can easily add new Tools to the project
- RenderTexture assets are used to integrate UI with drawing logic (Color Square, Canvas, Grid background behind, Preview). It isn't the only solution but it nicely separates our code from the UI
Main Scripts:
- DrawingManager.cs: Coordinates the various drawing tools and manages the overall drawing process, including tool selection, canvas updates, and user interactions.
- UIController.cs: Manages the user interface elements and their interactions within the Drawing application.
- DrawingAlgorithms.cs: Contains static methods for drawing algorithms, such as Bresenham's line algorithm, to generate pixel lines between points.
- DrawingTool.cs: Abstract base class for different drawing tools, responsible for applying changes to the canvas.
- TextureRendererHelper.cs: Provides utility functions for rendering textures to RenderTexture objects in Unity.
- DrawingRenderer.cs: Handles the rendering of drawings on the canvas, including drawing, previewing, and clearing operations.
-
ColorSelector.cs: Manages color selection and conversion, allowing users to pick and set colors for drawing.
How To Use
- Download the .zip file containing the project.
- Unpack it to a separate folder (this folder name will appear in Unity Hub).
- Install Unity 6000.0.23f1 or later.
- Open the project using Unity Hub -> Projects -> Add project from disk.
- From the "Scenes" folder open the SampleScene
- You can modify the canvas size from DrawingRenderer in the hierarchy
Development Notes
- All scripts are thoroughly commented to explain their functionality. You can find them inside "_Scripts" folder
- The project is updated to the Unity 6 release version (6000.0.23f1)
- Ongoing improvements focus on enhancing modularity and fixing any emerging issues.