broken
This commit is contained in:
46
Runtime/Engine/Code/Services/Development/DevToolsService.cs
Normal file
46
Runtime/Engine/Code/Services/Development/DevToolsService.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using RebootKit.Engine.Foundation;
|
||||
using RebootKit.Engine.Services.Console;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RebootKit.Engine.Services.Development {
|
||||
static class DebugCVars {
|
||||
public const string k_OverlayMode = "debug.mode";
|
||||
}
|
||||
|
||||
public class DevToolsService : ServiceMonoBehaviour {
|
||||
[SerializeField] DebugOverlayView m_DebugOverlayView;
|
||||
|
||||
[CVar(DebugCVars.k_OverlayMode, 1)] CVar m_OverlayMode;
|
||||
|
||||
IDisposable m_CVarChangedListener;
|
||||
|
||||
void OnEnable() {
|
||||
m_CVarChangedListener = RR.CVarChanged.Listen(OnCVarChanged);
|
||||
OnOverlayModeChanged(m_OverlayMode.IndexValue);
|
||||
}
|
||||
|
||||
void OnDisable() {
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
m_CVarChangedListener.Dispose();
|
||||
}
|
||||
|
||||
void OnOverlayModeChanged(int mode) {
|
||||
if (mode == 1) {
|
||||
m_DebugOverlayView.Show(destroyCancellationToken).Forget();
|
||||
} else {
|
||||
m_DebugOverlayView.Hide(destroyCancellationToken).Forget();
|
||||
}
|
||||
}
|
||||
|
||||
void OnCVarChanged(string cvarName, CVarValue value) {
|
||||
if (cvarName == DebugCVars.k_OverlayMode) {
|
||||
OnOverlayModeChanged((int)value.numberValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user