private void Update() { if (cam == null && Input.GetMouseButtonDown(0)) { var ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; if (Physics.Raycast(ray, out hitInfo)) { paintObject = hitInfo.transform.GetComponent <DynamicCanvas>(); if (paintObject != null) { uv = hitInfo.textureCoord; var camObj = Instantiate(camPref, hitInfo.point, Quaternion.LookRotation(hitInfo.normal), hitInfo.transform) as GameObject; cam = camObj.GetComponent <Camera>(); cam.targetTexture = rt; camObj.SetActive(true); } } } else if (cam != null) { var buf = RenderTexture.GetTemporary(brush.BrushTexture.width, brush.BrushTexture.height); Es.Effective.GrabArea.Clip(brush.BrushTexture, brush.Scale, rt, Vector3.one * 0.5f, Es.Effective.GrabArea.GrabTextureWrapMode.Clip, buf); Es.Effective.ReverseUV.Horizontal(buf, buf); var brushBuf = brush.BrushTexture; brush.BrushTexture = buf; if (paintObject != null) { paintObject.PaintUVDirect(brush, uv); } RenderTexture.ReleaseTemporary(buf); brush.BrushTexture = brushBuf; } }