Skip to content

Instantly share code, notes, and snippets.

@hecomi
Last active September 5, 2018 06:43
Show Gist options
  • Save hecomi/2b77453b8ce9b9007318de0e85e5b0ba to your computer and use it in GitHub Desktop.
Save hecomi/2b77453b8ce9b9007318de0e85e5b0ba to your computer and use it in GitHub Desktop.
...
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