MD Package Technical & APi Documentation
MDG_MeshPaint
Namespace: MDPackage.Geometry
Complete solution of simple mesh painting in Unity engine for multiple platforms. Apply this script to any gameObject and assign required fields.
Read more here (Online documentation slide)

The input is not handled by default, as the Unity Engine has many options for handling input and controls in general.
MD-Package components that contain some input features consist of 'Input Hookup' properties that handle the input in a generic way.
You can set these properties from your own input system. The component will display more information about the input setup, so please follow up on this information.
You can find all the input-hookup properties below.
Public Methods
// Paint mesh on the specific location by the selected paint status
public void MeshPaint_Paint(Vector3 currentPosition, MeshPaintStatus meshPaintStatus)
// Change brush size manually
public void MeshPaint_ChangeBrushSize(float size)
// Increase brush size manually
public void MeshPaint_IncreaseBrushSize(float size)
// Decrease brush size manually
public void MeshPaint_DecreaseBrushSize(float size)
// Enable/ Disable drawing externally
public void MeshPaint_EnableDisablePainting(bool paintStatus)
// Change currently selected material/color by index
public void MeshPaint_ChangeAppearanceIndex(int index)
// Change geometry type index (0 = Plane, 1 = Triangle, 2 = Cube)
public void MeshPaint_ChangeGeometryType(int geometryIndex)
Public Fields and Properties
// Input Hookups

// Use this input hookup for cursor/touch world screen position
public Vector3 InputHook_CursorScreenPosition { get; set; }
// Use this input hookup for generic button down
public bool InputHook_GenericButtonDown { get; set; }

// Events

// Invoked when the mesh has been painted (Invoked once at the end of the painting) - includes the painted mesh-gameObject in the parameters
public event Action<GameObject> PaintOnMeshPaintEnd;
// Invoked when the mesh is going to be painted (Invoked once at the beginning of the painting) - includes the painting mesh-gameObject in the parameters
public event Action<GameObject> PaintOnMeshPaintStart;

// Fields

// Brush settings
public bool paintBrushUniformSize = true;
public float paintBrushSize = 0.5f;
public Vector3 paintBrushVectorSize = Vector3.one;

public bool paintSmoothBrushMovement = true;
public float paintSmoothBrushMovementSpeed = 10f;
public bool paintSmoothBrushRotation = true;
public float paintSmoothBrushRotationSpeed = 20;

public bool paintVertexDistanceLimitation = true;
public float paintMinVertexDistance = 0.5f;

public bool paintConnectMeshOnRelease = false;

public MeshPaintType paintPaintingType; // DrawOnScreen, DrawOnRaycastHit, CustomDraw
public MeshPaintRotationType paintPaintingRotationType = MeshPaintRotationType.FollowOneAxis; // FollowOneAxis, FollowSpatialAxis
public Vector3 paintRotationOffsetEuler = new Vector3(0f, 0f, -1f);

public MeshPaintGeometryType paintGeometryType; // Plane, Triangle, Cube

// Type - screen
public bool paint_TypeScreen_UseMainCamera = true;
public Camera paint_TypeScreen_TargetCamera;
public float paint_TypeScreen_Depth = 10.0f;
// Type - raycast
public bool paint_TypeRaycast_RaycastFromCursor = true;
public Transform paint_TypeRaycast_RaycastOriginFORWARD;
public LayerMask paint_TypeRaycast_AllowedLayers = -1;
public bool paint_TypeRaycast_CastAllObjects = true;
public string paint_TypeRaycast_TagForRaycast;
public Vector3 paint_TypeRaycast_BrushOffset = new Vector3(0, 1, 0);
public bool paint_TypeRaycast_IgnoreSelfCasting = true;
// Type - custom
public bool paint_TypeCustom_IsPainting = false;
private bool paint_TypeCustom_PaintingStarted = false;
public bool paint_TypeCustom_CustomBrushTransform = true;
public bool paint_TypeCustom_EnableSmartRotation = true;
public Transform paint_TypeCustom_BrushParent;

// Appearance
public int paintSelectedAppearanceSlot = 0;
public bool paintUseMaterialSlots = false;
public Material[] paintMaterialSlots;
public Color[] paintColorSlots = new Color[1] { Color.blue };

public bool paintUseCustomBrushTransform = false;
public Transform paintCompleteCustomBrush;
public bool paintHideCustomBrushIfNotRaycasting = true;

public bool paintHandleMeshCollider = true;
Examples
The following paragraphs contain Mesh Paint used in a practical example. Create a mesh paint script at runtime and modify the painted mesh.
using UnityEngine;
using MDPackage.Geometry;

public class SampleScript : MonoBehaviour
{
private MDG_MeshPaint paint;

private void Start()
 {
  // Add MeshPaint and subscribe to an event when mesh-painting ends
  paint = gameObject.AddComponent<MDG_MeshPaint>();
  paint.PaintOnMeshPaintEnd += MeshPaintEnd;
 }

private void OnDestroy()
 {
  paint.PaintOnMeshPaintEnd -= MeshPaintEnd;
 }

private void MeshPaintEnd(GameObject paintedObject)
 {
  // Do whatever you wish with the painted chunk...
  // Change the painted object's material color to red (or modify this as you wish)
  paintedObject.GetComponent<Renderer>().material.color = Color.red;
 }

private void Update()
 {
  if (paint == null)
   return;

  // Pass the input - PC-keyboard (you can adapt this with your own input system)
  paint.InputHook_CursorScreenPosition = Input.mousePosition;
  paint.InputHook_GenericButtonDown = Input.GetKey(KeyCode.Mouse0);
 }
}