diff --git a/MLEM.Ui/Elements/Element.cs b/MLEM.Ui/Elements/Element.cs index b8d058b..e14157a 100644 --- a/MLEM.Ui/Elements/Element.cs +++ b/MLEM.Ui/Elements/Element.cs @@ -442,7 +442,8 @@ namespace MLEM.Ui.Elements { this.System.OnElementUpdated?.Invoke(this, time); foreach (var child in this.GetRelevantChildren()) - child.Update(time); + if (child.System != null) + child.Update(time); } public virtual void Draw(GameTime time, SpriteBatch batch, float alpha, BlendState blendState, SamplerState samplerState, Matrix matrix) { diff --git a/MLEM.Ui/UiSystem.cs b/MLEM.Ui/UiSystem.cs index c592b90..a69b417 100644 --- a/MLEM.Ui/UiSystem.cs +++ b/MLEM.Ui/UiSystem.cs @@ -98,8 +98,9 @@ namespace MLEM.Ui { public void Update(GameTime time) { this.Controls.Update(); - foreach (var root in this.rootElements) - root.Element.Update(time); + for (var i = this.rootElements.Count - 1; i >= 0; i--) { + this.rootElements[i].Element.Update(time); + } } public void DrawEarly(GameTime time, SpriteBatch batch) {