working on multiplayer
This commit is contained in:
50
Runtime/Engine/Code/Development/DevToolsService.cs
Normal file
50
Runtime/Engine/Code/Development/DevToolsService.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
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", 0, "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;
|
||||
OnCVarChanged(DebugConfig.s_OverlayMode);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user