Runtime integration
Camera Behavior And API
Attach the overlay to the intended camera and wire Show, Hide, Toggle, or Visible into debug controls.
- Camera resolution
- Runtime API
- Legacy input
- Sample bootstrap
The overlay renders as a child object of a Unity camera. It can auto-attach for simple scenes, but explicit camera assignment is best for complex camera setups.
Camera Behavior
If Target Camera is assigned, that camera is used as long as it is active and enabled.
If no target camera is assigned, the overlay resolves a camera in this order:
- The currently attached active game camera.
Camera.main.- The first active enabled camera with
CameraType.Game.
This makes the component easy to drop into simple projects while still allowing explicit setup for projects with multiple cameras, split-screen views, camera stacks, or custom camera lifecycles.
For multi-camera projects, assign Target Camera directly so the overlay appears on the intended view.
Runtime API
Use the public API when you want to wire the overlay into your own debug console, keyboard shortcuts, developer menu, pause menu, or build-specific diagnostics system.
using Azkar.ScreenStats;
using UnityEngine;
public sealed class DebugOverlayToggle : MonoBehaviour
{
[SerializeField] private ScreenStatsOverlay overlay;
private void Update()
{
if (Input.GetKeyDown(KeyCode.F3))
{
overlay.Toggle();
}
}
}Available members:
overlay.Show();
overlay.Hide();
overlay.Toggle();
bool visible = overlay.Visible;
overlay.Visible = true;
overlay.Visible = false;Visible controls the renderer without disabling the GameObject, so external input and scripts can still call Toggle() while the overlay is hidden.
Legacy Input Toggle
When the Unity legacy input manager define is available, the component includes an optional Legacy Toggle Key field. The default is the backquote key.
Projects using the newer Input System should call Toggle() from their own input action callback or debug menu.
Sample Bootstrap
The included sample is intentionally small so it can be copied, modified, or replaced.
ScreenStatsBootstrap does the following:
- Searches for an existing
ScreenStatsOverlay. - If one exists, it does nothing.
- If none exists, it creates a new GameObject named
Azkar Screen Stats. - Adds
ScreenStatsOverlay. - Optionally calls
DontDestroyOnLoad.
This is useful for test scenes, development builds, or projects where you want one global overlay without manually adding it to every scene.
