Last active
September 5, 2018 06:43
-
-
Save hecomi/2b77453b8ce9b9007318de0e85e5b0ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
var ray = new Ray(); | |
ray.origin = gripTransform.position; | |
ray.direction = gripTransform.forward; | |
RaycastHit hit; | |
if (Physics.Raycast(ray, out hit, maxRayDistance, layerMask)) | |
{ | |
var rb = targetHit_.rigidbody; | |
var uwcWinObj = | |
rb.GetComponent<uWindowCapture.UwcWindowObject>() ?? | |
rb.GetComponentInChildren<uWindowCapture.UwcWindowObject>(); | |
if (uwcWinObj) | |
{ | |
var window = uwcWinObj.window; | |
var localPos = uwcWinObj.transform.InverseTransformPoint(targetHit_.point); | |
var windowLocalX = (int)((localPos.x + 0.5f) * window.width); | |
var windowLocalY = (int)((0.5f - localPos.y) * window.height); | |
var desktopX = window.x + windowLocalX; | |
var desktopY = window.y + windowLocalY; | |
var coord = new Vector2(desktopX, desktopY); | |
NwndWin32API.SetForegroundWindow(window.handle); | |
NwndWin32API.SetFocus(window.handle); | |
touchDispatcher.Touch(coord); | |
} | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment