What is content provider

ContentProvider is a base class for a content of a DebugPanel. It populates content for panel and links it with your games systems.

image.png

Its main method is PopulateContent(DebugPanel panel)

image.png

<aside> 💡

There is also horizontal and vertical populate methods for different layouts depending on aspect ratio, see more in Horizontal And Vertical Layout

</aside>

In editor

Debug panel should have a content provider, it will show the current provider in its editor

image.png

And if no content provider found will suggest to attach one

image.png

Sample overview

Sample provider script ContentProviderExample.cs

Here is all of the code for content creation is defined.

As you can see from first lines there is few concepts, the groups and the buttons presented. Groups is similar to IMGUI in editor, where you need to being/end group calls, and its content in between.

Using panel.BeginGroup() /panel.EndGroup() is one way to define a group.

Usepanel.AddButton() to add simples panel ui element - button, with name and click callback.

image.png

Below there is a way to define group with scope struct Group : IDisposable utilizing using statement. This makes sure you don’t forget to end the group.