FNA-VSCode-Template/project_name/DemoComponent.cs
2019-09-20 23:12:31 -07:00

35 lines
1014 B
C#
Executable File

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();
}
}
}