/// <summary> /// Run raycast test for window at given point on the screen. /// </summary> internal static bool TestRaycast(Vector2 screenPoint, [NotNull] Func <EnhancedGUIWindow, Rect> getScreen, out EnhancedGUIWindow window) { if (getScreen == null) { throw new ArgumentNullException(nameof(getScreen)); } window = default(EnhancedGUIWindow); var allWindows = new List <EnhancedGUIWindow>(); foreach (var r in Renderers) { allWindows.AddRange(r.Windows); } var sorted = allWindows.OrderBy(o => o.Depth); foreach (var s in sorted) { var screen = getScreen.Invoke(s); if (!screen.Contains(screenPoint)) { continue; } window = s; break; } return(!window.Equals(default(EnhancedGUIWindow))); }
/// <summary> /// Get rect for next window. /// </summary> internal static Rect NextWindow(string name, out bool isContentActive, out bool isWindowOpen, out int depth, out string guid) { EnhancedGUIWindow window; if (Renderer.WindowsIndex >= Renderer.Windows.Length) { if (!EnhancedGUISave.GetWindowRect(name, out var rect, out var active)) { rect = new Rect(LastWindow.Rect.x + 20f, LastWindow.Rect.y + 20f, 300f, 200f); isContentActive = true; } else { isContentActive = active; } window = LastWindow = new EnhancedGUIWindow(Guid.NewGuid().ToString(), name) { Rect = rect, Depth = _isFirstRect ? 0 : Renderer.WindowsIndex + 1 }; var list = new List <EnhancedGUIWindow>(Renderer.Windows) { window }; Renderer.Windows = list.ToArray(); Renderer.WindowsIndex++; }