Skip to content

Commit

Permalink
feat: enable update
Browse files Browse the repository at this point in the history
  • Loading branch information
Rofli Sanches committed May 15, 2021
1 parent 74434a5 commit 72aec49
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 30 deletions.
63 changes: 33 additions & 30 deletions Source/UImGui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,40 +179,43 @@ private void OnDisable()
_renderCommandBuffer = null;
}

private void Reset()
private void Update()
{
_camera = Camera.main;
_initialConfiguration.SetDefaults();
UImGuiUtility.SetCurrentContext(_context);
ImGuiIOPtr io = ImGui.GetIO();

Constants.PrepareFrameMarker.Begin(this);
_context.TextureManager.PrepareFrame(io);
_platform.PrepareFrame(io, _camera.pixelRect);
ImGui.NewFrame();
Constants.PrepareFrameMarker.End();

Constants.LayoutfMarker.Begin(this);
try
{
if (_doGlobalLayout)
{
UImGuiUtility.DoLayout();
}

Layout?.Invoke();
}
finally
{
ImGui.Render();
Constants.LayoutfMarker.End();
}

Constants.DrawListMarker.Begin(this);
_renderCommandBuffer.Clear();
_renderer.RenderDrawLists(_renderCommandBuffer, ImGui.GetDrawData());
Constants.DrawListMarker.End();
}

private void Update()
private void Reset()
{
//ImGuiUn.SetUnityContext(_context);
//ImGuiIOPtr io = ImGui.GetIO();

//s_prepareFramePerfMarker.Begin(this);
//_context.textures.PrepareFrame(io);
//_platform.PrepareFrame(io, _camera.pixelRect);
//ImGui.NewFrame();
//s_prepareFramePerfMarker.End();

//s_layoutPerfMarker.Begin(this);
//try
//{
// if (_doGlobalLayout)
// ImGuiUn.DoLayout(); // ImGuiUn.Layout: global handlers
// Layout?.Invoke(); // this.Layout: handlers specific to this instance
//}
//finally
//{
// ImGui.Render();
// s_layoutPerfMarker.End();
//}

//s_drawListPerfMarker.Begin(this);
//_cmd.Clear();
//_renderer.RenderDrawLists(_cmd, ImGui.GetDrawData());
//s_drawListPerfMarker.End();
_camera = Camera.main;
_initialConfiguration.SetDefaults();
}

private void SetRenderer(IRenderer renderer, ImGuiIOPtr io)
Expand Down
3 changes: 3 additions & 0 deletions Source/Utils/UImGuiUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ namespace UImGui
{
internal static class UImGuiUtility
{
public static event Action Layout; // Global/default Layout event, each DearImGui instance also has a private one.
internal static void DoLayout() => Layout?.Invoke();

internal static Context Context;

internal static Context CreateContext()
Expand Down

0 comments on commit 72aec49

Please sign in to comment.