forked from oyster-catcher/HopperGuidance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGuiUtils.cs
30 lines (27 loc) · 924 Bytes
/
GuiUtils.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using System.Text.RegularExpressions;
using UnityEngine;
namespace HopperGuidance
{
static public class GuiUtils
{
public static bool OverPartWindow(Part part, Vector2d mouse)
{
bool symmetry = false;
UIPartActionWindow window = UIPartActionController.Instance.GetItem(part, symmetry);
return window.Hover;
}
public static bool GetMouseHit(CelestialBody body, out RaycastHit hit, Part part)
{
if ((part!=null) && OverPartWindow(part, Input.mousePosition))
{
hit = new RaycastHit();
return false;
}
// Cast a ray from screen point
Ray ray = FlightCamera.fetch.mainCamera.ScreenPointToRay(Input.mousePosition);
bool isHit = Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity, 1 << 15);
return isHit;
}
}
}