12 private enum UseMethodType
20 [SerializeField]
private Brush brush;
22 [SerializeField]
private UseMethodType useMethodType = UseMethodType.RaycastHitInfo;
24 [SerializeField]
bool erase;
28 if (Input.GetMouseButton(0))
30 var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
33 if (Physics.Raycast(ray, out hitInfo))
35 var paintObject = hitInfo.transform.GetComponent<
InkCanvas>();
36 if (paintObject !=
null)
37 switch (useMethodType)
39 case UseMethodType.RaycastHitInfo:
40 success = erase ? paintObject.
Erase(brush, hitInfo) : paintObject.Paint(brush, hitInfo);
43 case UseMethodType.WorldPoint:
45 ? paintObject.Erase(brush, hitInfo.point)
46 : paintObject.Paint(brush, hitInfo.point);
49 case UseMethodType.NearestSurfacePoint:
51 ? paintObject.EraseNearestTriangleSurface(brush, hitInfo.point)
52 : paintObject.PaintNearestTriangleSurface(brush, hitInfo.point);
55 case UseMethodType.DirectUV:
56 if (!(hitInfo.collider is MeshCollider))
57 Debug.LogWarning(
"Raycast may be unexpected if you do not use MeshCollider.");
59 ? paintObject.EraseUVDirect(brush, hitInfo.textureCoord)
60 : paintObject.PaintUVDirect(brush, hitInfo.textureCoord);
64 Debug.LogError(
"Failed to paint.");
71 if (GUILayout.Button(
"Reset"))
72 foreach (var canvas
in FindObjectsOfType<InkCanvas>())
Class managing brush information.
Texture paint to canvas. To set the per-material.
bool Erase(Brush brush, Vector3 worldPos, Func< PaintSet, bool > materialSelector=null, Camera renderCamera=null)
Erase processing that use world-space surface position.