public void RenderChildren()
 {
     for (int i = 0; i < Children.Count; i++)
     {
         SElement child = Children[i];
         child.Root   = Root;
         child.Parent = this;
         if (!child.Visible)
         {
             continue;
         }
         child.Render();
     }
 }
示例#2
0
        public void OnGUI()
        {
            SGUIRoot root = CurrentRoot;

            if (_Reason.isMouse || _Reason.type == EventType.ScrollWheel)
            {
                LastMouseEventConsumed = HandleMouseEvent(Event.current) != -1;
                return;
            }

            // Your normal rendering run.
            for (int i = 0; i < root.Children.Count; i++)
            {
                SElement child = root.Children[i];
                child.Root   = root;
                child.Parent = null;
                if (!child.Visible)
                {
                    continue;
                }
                child.Render();
            }

            // After the normal (possibly) repaint run, check for any mouse movement.
            if (IsOnGUIRepainting)
            {
                Vector2 mousePosition = Input.mousePosition;
                mousePosition = new Vector2(
                    mousePosition.x,
                    root.Size.y - mousePosition.y - 1f
                    );
                if (_LastMousePosition.x <= -1f && _LastMousePosition.y <= -1f)
                {
                    _LastMousePosition = mousePosition;
                }
                else
                {
                    HandleMouseEvent(new Event(Event.current.displayIndex)
                    {
                        type          = EventType.MouseMove,
                        mousePosition = mousePosition,
                        delta         = mousePosition - _LastMousePosition
                    });
                    _LastMousePosition = mousePosition;
                }
            }
        }