void Update() { if (Input.GetKeyDown(KeyCode.Space)) { Init(); } // to here if (draw) { for (int i = 0; i < 2; i++) { lerpCords = Vector2.MoveTowards(lastUVCords, currentCords, brushSize * 0.001f); activeSurface.RegisterRay(lerpCords, scaledBrush, intencity, color); lastUVCords = lerpCords; } } }
// Update is called once per frame void FixedUpdate() { if (!brushActivated) { return; } RaycastHit hit; Debug.DrawRay(pointer.position, pointer.forward * rayReach); if (Physics.Raycast(pointer.position, pointer.forward, out hit, rayReach, paintLayers.value)) { //Debug.Log ("Raycast hit"); activeSurface = hit.transform.root.GetComponent <PaintableObject> (); if (activeSurface != null) { draw = true; currentCords = hit.textureCoord; if (resetBrushCords || lastSurface != activeSurface) { scaledBrush = Instantiate(activeBrush); TextureScale.Bilinear(scaledBrush, (int)(brushSize * ((float)activeSurface.textureSize / 256)), (int)(brushSize * ((float)activeSurface.textureSize / 256))); //Debug.Log (scaledBrush.format); lastUVCords = currentCords; resetBrushCords = false; activeSurface.RegisterRay(currentCords, scaledBrush, intencity, color); lastUVCords = currentCords; lastSurface = activeSurface; return; } /// Draw from here } else { draw = false; } } else { draw = false; } }