51 lines
1.5 KiB
C#
51 lines
1.5 KiB
C#
using System;
|
|
using RebootKit.Engine.Foundation;
|
|
using RebootKit.Engine.Services.Console;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
namespace RebootKit.Engine.Services.Development {
|
|
static class DebugConfig {
|
|
[ConfigVar("debug.overlay", 1, "Controls overlay visibility. 0 - hidden, 1 - visible")] public static ConfigVar s_OverlayMode;
|
|
}
|
|
|
|
public class DevToolsService : ServiceMonoBehaviour {
|
|
[SerializeField] DebugOverlayView m_DebugOverlayView;
|
|
|
|
|
|
IDisposable m_CVarChangedListener;
|
|
|
|
void Start() {
|
|
ConfigVar.StateChanged += OnCVarChanged;
|
|
// OnOverlayModeChanged(m_OverlayMode.IndexValue);
|
|
}
|
|
|
|
void OnDisable() {
|
|
Dispose();
|
|
}
|
|
|
|
public override void Dispose() {
|
|
ConfigVar.StateChanged -= OnCVarChanged;
|
|
}
|
|
|
|
void Update() {
|
|
if (InputSystem.GetDevice<Keyboard>().f3Key.wasReleasedThisFrame) {
|
|
DebugConfig.s_OverlayMode.Set(DebugConfig.s_OverlayMode.IndexValue == 1 ? 0 : 1);
|
|
}
|
|
}
|
|
|
|
void OnOverlayModeChanged(int mode) {
|
|
if (mode == 1) {
|
|
m_DebugOverlayView.gameObject.SetActive(true);
|
|
} else {
|
|
m_DebugOverlayView.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
void OnCVarChanged(ConfigVar cvar) {
|
|
if (cvar == DebugConfig.s_OverlayMode) {
|
|
OnOverlayModeChanged(cvar.IndexValue);
|
|
}
|
|
}
|
|
}
|
|
} |