2 using Microsoft.Xna.Framework;
3 using Microsoft.Xna.Framework.Graphics;
24 throw new InvalidOperationException($
"Children were found in {nameof(GUIScissorComponent)}, Add them to {nameof(GUIScissorComponent)}.{nameof(Content)} instead.");
27 public override void DrawChildren(SpriteBatch spriteBatch,
bool recursive)
33 protected override void Draw(SpriteBatch spriteBatch)
37 Rectangle prevScissorRect = spriteBatch.GraphicsDevice.ScissorRectangle;
38 RasterizerState prevRasterizerState = spriteBatch.GraphicsDevice.RasterizerState;
41 spriteBatch.GraphicsDevice.ScissorRectangle =
Rectangle.Intersect(prevScissorRect,
Rect);
46 if (!child.
Visible) {
continue; }
47 child.
DrawManually(spriteBatch, alsoChildren:
true, recursive:
true);
51 spriteBatch.GraphicsDevice.ScissorRectangle = prevScissorRect;
52 spriteBatch.Begin(SpriteSortMode.Deferred, samplerState: GUI.SamplerState, rasterizerState: prevRasterizerState);
55 protected override void Update(
float deltaTime)
57 base.Update(deltaTime);
61 private static void ClampChildMouseRects(
GUIComponent child)
69 ClampChildMouseRects(grandChild);
78 GUI.AddToUpdateList(
this);
88 if (!child.
Visible) {
continue; }
GUIComponent(string style, RectTransform rectT)
This is the new constructor.
bool ClampMouseRectToParent
virtual void AddToGUIUpdateList(bool ignoreChildren=false, int order=0)
Action< GUIComponent > OnAddedToGUIUpdateList
virtual void DrawManually(SpriteBatch spriteBatch, bool alsoChildren=false, bool recursive=true)
By default, all the gui elements are drawn automatically in the same order they appear on the update ...
RectTransform RectTransform
IEnumerable< GUIComponent > Children
override void AddToGUIUpdateList(bool ignoreChildren=false, int order=0)
override void Update(float deltaTime)
override void DrawChildren(SpriteBatch spriteBatch, bool recursive)
Draws all the children manually.
override void Draw(SpriteBatch spriteBatch)
GUIScissorComponent(RectTransform rectT)
static RasterizerState ScissorTestEnable