game version overlay, working on actors sync
This commit is contained in:
@@ -26,9 +26,9 @@ namespace RebootKit.Engine.Development {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.Append("Network: ");
|
||||
sb.Append($"IsServer: {nm.IsServer}");
|
||||
sb.Append($" | IsClient: {nm.IsClient}");
|
||||
sb.Append($" | IsHost: {nm.IsHost}");
|
||||
sb.Append($"IsServer: {nm.IsServer.ToString()}");
|
||||
sb.Append($" | IsClient: {nm.IsClient.ToString()}");
|
||||
sb.Append($" | IsHost: {nm.IsHost.ToString()}");
|
||||
|
||||
m_NetworkStatsLabel.text = sb.ToString();
|
||||
}
|
||||
@@ -37,7 +37,7 @@ namespace RebootKit.Engine.Development {
|
||||
m_RootElement = new VisualElement();
|
||||
|
||||
CreateLabel($"Toggle Overlay [F3] | RebootKit | game: {Application.productName}, version: {Application.version}");
|
||||
m_FPSLabel = CreateLabel($"FPS: {Application.targetFrameRate}");
|
||||
m_FPSLabel = CreateLabel($"FPS: {Application.targetFrameRate.ToString()}");
|
||||
|
||||
m_NetworkStatsLabel = CreateLabel("Network Stats");
|
||||
|
||||
|
||||
@@ -4,18 +4,29 @@ using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace RebootKit.Engine.Development {
|
||||
static class DebugConfig {
|
||||
[ConfigVar("debug.overlay", 0, "Controls overlay visibility. 0 - hidden, 1 - visible")] public static ConfigVar s_OverlayMode;
|
||||
static class DebugCVars {
|
||||
[ConfigVar("debug.overlay", 0, "Controls overlay visibility. 0 - hidden, 1 - visible")]
|
||||
public static ConfigVar OverlayMode;
|
||||
|
||||
[ConfigVar("debug.game_version", 1, "Controls game version overlay visibility. 0 - hidden, 1 - visible")]
|
||||
public static ConfigVar ShowGameVersion;
|
||||
|
||||
[ConfigVar("debug.network_stats", 1, "Controls network stats overlay visibility. 0 - hidden, 1 - visible")]
|
||||
public static ConfigVar ShowNetworkStats;
|
||||
}
|
||||
|
||||
public class DevToolsService : ServiceMonoBehaviour {
|
||||
[SerializeField] DebugOverlayView m_DebugOverlayView;
|
||||
[SerializeField] GameVersionOverlay m_GameVersionOverlay;
|
||||
[SerializeField] GameObject m_NetworkStatsOverlay;
|
||||
|
||||
IDisposable m_CVarChangedListener;
|
||||
|
||||
void Start() {
|
||||
ConfigVar.StateChanged += OnCVarChanged;
|
||||
OnCVarChanged(DebugConfig.s_OverlayMode);
|
||||
OnCVarChanged(DebugCVars.OverlayMode);
|
||||
OnCVarChanged(DebugCVars.ShowGameVersion);
|
||||
OnCVarChanged(DebugCVars.ShowNetworkStats);
|
||||
}
|
||||
|
||||
void OnDisable() {
|
||||
@@ -28,7 +39,7 @@ namespace RebootKit.Engine.Development {
|
||||
|
||||
void Update() {
|
||||
if (InputSystem.GetDevice<Keyboard>().f3Key.wasReleasedThisFrame) {
|
||||
DebugConfig.s_OverlayMode.Set(DebugConfig.s_OverlayMode.IndexValue == 1 ? 0 : 1);
|
||||
DebugCVars.OverlayMode.Set(DebugCVars.OverlayMode.IndexValue == 1 ? 0 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +52,12 @@ namespace RebootKit.Engine.Development {
|
||||
}
|
||||
|
||||
void OnCVarChanged(ConfigVar cvar) {
|
||||
if (cvar == DebugConfig.s_OverlayMode) {
|
||||
if (cvar == DebugCVars.OverlayMode) {
|
||||
OnOverlayModeChanged(cvar.IndexValue);
|
||||
} else if (cvar == DebugCVars.ShowGameVersion) {
|
||||
m_GameVersionOverlay.gameObject.SetActive(cvar.IndexValue > 0);
|
||||
} else if (cvar == DebugCVars.ShowNetworkStats) {
|
||||
m_NetworkStatsOverlay.SetActive(cvar.IndexValue > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
34
Runtime/Engine/Code/Development/GameVersionOverlay.cs
Normal file
34
Runtime/Engine/Code/Development/GameVersionOverlay.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using RebootKit.Engine.Foundation;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace RebootKit.Engine.Development {
|
||||
public class GameVersionOverlay : MonoBehaviour {
|
||||
const string k_VersionLabelName = "rr-dev__version_label";
|
||||
|
||||
[SerializeField] UIDocument m_Document;
|
||||
|
||||
void OnEnable() {
|
||||
Label versionLabel = m_Document.rootVisualElement.Q<Label>(k_VersionLabelName);
|
||||
versionLabel.text = BuildLabel();
|
||||
}
|
||||
|
||||
string BuildLabel() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("ver. ");
|
||||
sb.Append(Application.version);
|
||||
|
||||
#if RR_DEBUG
|
||||
sb.Append(" (RR_DEBUG)");
|
||||
#endif
|
||||
|
||||
#if RR_STEAM
|
||||
sb.Append(" (RR_STEAM)");
|
||||
#endif
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8faa5154dbc44f83ae3fa5c6057c11bb
|
||||
timeCreated: 1752494644
|
||||
Reference in New Issue
Block a user