You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I use Nez since its a nice addon to Monogame and works great with dotnet6.
And I wanted to use MGUI as it has to many features to easy setup UI inside of the game.
Since it took me some minutes to understand how to integrate the both I thought lets share it here :)
Guide
This is what I needed to do to get this to work:
Follow the Setup guide.
My vscode solution explorer looked afterwards like this:
usingSystem;usingSystem.Collections.Generic;usingengine;usingMGUI.Core.UI;// addusingMGUI.Core.UI.Brushes.Fill_Brushes;//addusingMGUI.Shared.Rendering;//addusingMicrosoft.Xna.Framework;usingMicrosoft.Xna.Framework.Graphics;usingNez;usingNez.Sprites;usingNez.UI;namespacemodwars;publicclassGame1:Nez.Core,IObservableUpdate// Add IObservableUpdate {protectedGameManagerGameManager=new();protectedList<string>AvailableGameScenes=new();protectedMGDesktopUIMainScreen;//addprotectedMainRendererUIMainRenderer;//addpubliceventEventHandler<TimeSpan>PreviewUpdate;//addpubliceventEventHandler<EventArgs>EndUpdate;//addprotectedoverridevoidInitialize(){base.Initialize();// TODO all the setup on gamestart here// first sceneCore.DebugRenderEnabled=true;AvailableGameScenes=GameManager.SetupScenes("BuilderUiTestScene");// my function to setup scenes// TEST UI CODE FROM TUTORIALthis.UIMainRenderer=new(newGameRenderHost<Game1>(this));this.UIMainScreen=new(this.UIMainRenderer);MGWindowWindow1=new(UIMainScreen,50,50,500,200);Window1.TitleText="Sample Window with a single [b]Button[/b]: [color=yellow]Click it![/color]";Window1.BackgroundBrush.NormalValue=newMGSolidFillBrush(Color.Orange);Window1.Padding=new(15);MGButtonButton1=new(Window1, button =>{button.SetContent("I've been clicked!");});Button1.SetContent("Click me!");Window1.SetContent(Button1);this.UIMainScreen.Windows.Add(Window1);}protectedoverridevoidUpdate(GameTimegameTime)// add and keep order of functions{PreviewUpdate?.Invoke(this,gameTime.TotalGameTime);base.Update(gameTime);UIMainScreen.Update();EndUpdate?.Invoke(this,EventArgs.Empty);}protectedoverridevoidDraw(GameTimegameTime)// add and keep order of functions{base.Draw(gameTime);// TODO: Add your drawing code hereUIMainScreen.Draw();}}
The text was updated successfully, but these errors were encountered:
So I use Nez since its a nice addon to Monogame and works great with dotnet6.
And I wanted to use MGUI as it has to many features to easy setup UI inside of the game.
Since it took me some minutes to understand how to integrate the both I thought lets share it here :)
Guide
This is what I needed to do to get this to work:
The text was updated successfully, but these errors were encountered: