mirror of
https://github.com/prime31/FNA-VSCode-Template.git
synced 2025-10-31 21:50:44 +07:00
Create DemoComponent.cs
This commit is contained in:
parent
e689a13d70
commit
6740dbd4e1
34
project_name/DemoComponent.cs
Normal file
34
project_name/DemoComponent.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using ImGuiNET;
|
||||
using Nez;
|
||||
using Nez.ImGuiTools;
|
||||
|
||||
namespace project_name
|
||||
{
|
||||
public class DemoComponent : Component
|
||||
{
|
||||
int _buttonClickCounter;
|
||||
|
||||
public override void onAddedToEntity()
|
||||
{
|
||||
// register with the ImGuiMangaer letting it know we want to render some IMGUI
|
||||
Core.getGlobalManager<ImGuiManager>().registerDrawCommand(imGuiDraw);
|
||||
}
|
||||
|
||||
public override void onRemovedFromEntity()
|
||||
{
|
||||
// remove ourselves when we are removed from the Scene
|
||||
Core.getGlobalManager<ImGuiManager>().unregisterDrawCommand(imGuiDraw);
|
||||
}
|
||||
|
||||
void imGuiDraw()
|
||||
{
|
||||
// do your actual drawing here
|
||||
ImGui.Begin("Your ImGui Window", ImGuiWindowFlags.AlwaysAutoResize);
|
||||
ImGui.Text("This is being drawn in DemoComponent");
|
||||
if(ImGui.Button($"Clicked me {_buttonClickCounter} times"))
|
||||
_buttonClickCounter++;
|
||||
ImGui.End();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user