/// <summary> /// Make the input waveform. /// </summary> /// <param name="waveform">Waveform texture.</param> /// <param name="worldPos">World position.</param> /// <param name="scale">Waveform scale.(The ratio of the size in the texture)</param> /// <param name="strength">Strength of input value.</param> public void Input(Texture2D waveform, Vector3 worldPos, float scale, float strength = 0.1f) { brush.BrushTexture = waveform; brush.Scale = scale; brush.HeightBlend = strength; inkCanvas.Paint(brush, worldPos); }
void PaintFunction() { //cast a ray from transform forward and paint hitpoint with brush texture Ray ray = new Ray(transform.position, transform.forward); RaycastHit hitInfo; if (!spray.isPlaying) { spray.Play(); } if (Physics.Raycast(ray, out hitInfo)) { if (!triangles.Contains(hitInfo.triangleIndex)) { triangles.Add(hitInfo.triangleIndex); hudManager.UpdatePaintingProgress(triangles.Count, totalTriangles); } if (canvasObject != null) { canvasObject.Paint(brush, hitInfo); } } direction = inputManager.DeltaPosition; transform.localPosition = new Vector3( Mathf.Lerp(transform.localPosition.x, Mathf.Clamp(transform.localPosition.x + (speed * direction.x) * Time.deltaTime, -2.5f, 2.5f), lerpTime), Mathf.Lerp(transform.localPosition.y, Mathf.Clamp(transform.localPosition.y + (speed * direction.y) * Time.deltaTime, -1f, 5f), lerpTime), transform.localPosition.z); }
private void Update() { if (Input.GetMouseButton(0)) { var ray = Camera.main.ScreenPointToRay(Input.mousePosition); bool success = true; RaycastHit hitInfo; if (Physics.Raycast(ray, out hitInfo)) { InkCanvas paintObject = hitInfo.transform.GetComponent <InkCanvas>(); if (paintObject != null) { success = paintObject.Paint(brush, hitInfo); } else { Debug.LogError("Failed to paint."); } } } }