阶段性打包
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
#if UNITY_EDITOR || DEVELOPMENT_BUILD
|
||||
using System;
|
||||
using System.Linq;
|
||||
using SepCore.Event;
|
||||
@@ -36,7 +35,9 @@ public class RuntimeDebugPanelComponent : MonoBehaviour
|
||||
[SerializeField] private bool _showPlayerHealthControls = true;
|
||||
[SerializeField] private bool _showTips = true;
|
||||
|
||||
private Rect _windowRect = new Rect(20f, 60f, 460f, 800f);
|
||||
private Rect _windowRect;
|
||||
private Vector2 _panelScroll;
|
||||
private GUISkin _panelSkin;
|
||||
private bool _isPanelVisible;
|
||||
private int _windowId;
|
||||
|
||||
@@ -77,17 +78,58 @@ public class RuntimeDebugPanelComponent : MonoBehaviour
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
DrawToggleButton();
|
||||
if (!_isPanelVisible) return;
|
||||
GUISkin previousSkin = GUI.skin;
|
||||
Matrix4x4 previousMatrix = GUI.matrix;
|
||||
if (_panelSkin == null)
|
||||
{
|
||||
_panelSkin = Instantiate(previousSkin);
|
||||
_panelSkin.label.fontSize = 18;
|
||||
_panelSkin.label.wordWrap = true;
|
||||
_panelSkin.button.fontSize = 18;
|
||||
_panelSkin.button.padding = new RectOffset(12, 12, 10, 10);
|
||||
_panelSkin.button.fixedHeight = 44f;
|
||||
_panelSkin.textField.fontSize = 20;
|
||||
_panelSkin.textField.fixedHeight = 44f;
|
||||
_panelSkin.textField.padding = new RectOffset(10, 10, 10, 10);
|
||||
_panelSkin.window.padding = new RectOffset(16, 16, 12, 16);
|
||||
_panelSkin.verticalScrollbar.fixedWidth = 28f;
|
||||
_panelSkin.verticalScrollbarThumb.fixedWidth = 28f;
|
||||
}
|
||||
|
||||
_windowRect = GUI.Window(_windowId, _windowRect, DrawWindow, "Runtime Debug Panel");
|
||||
Rect safeArea = Screen.safeArea;
|
||||
float scale = Mathf.Max(0.1f, Mathf.Min(safeArea.width, safeArea.height) / 480f);
|
||||
Rect bounds = new Rect(0f, 0f, safeArea.width / scale, safeArea.height / scale);
|
||||
try
|
||||
{
|
||||
GUI.skin = _panelSkin;
|
||||
GUI.matrix = Matrix4x4.TRS(
|
||||
new Vector3(safeArea.x, Screen.height - safeArea.yMax, 0f),
|
||||
Quaternion.identity, new Vector3(scale, scale, 1f));
|
||||
DrawToggleButton(bounds);
|
||||
if (!_isPanelVisible) return;
|
||||
|
||||
float width = Mathf.Min(460f, bounds.width - 24f);
|
||||
_windowRect = new Rect(bounds.width - width - 12f, 72f, width,
|
||||
Mathf.Min(760f, bounds.height - 84f));
|
||||
GUI.Window(_windowId, _windowRect, DrawWindow, string.Empty);
|
||||
}
|
||||
finally
|
||||
{
|
||||
GUI.matrix = previousMatrix;
|
||||
GUI.skin = previousSkin;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawToggleButton()
|
||||
private void OnDestroy()
|
||||
{
|
||||
const float width = 64f;
|
||||
const float height = 30f;
|
||||
Rect buttonRect = new Rect(Screen.width - width - 12f, 10f, width, height);
|
||||
if (_panelSkin != null) Destroy(_panelSkin);
|
||||
}
|
||||
|
||||
private void DrawToggleButton(Rect bounds)
|
||||
{
|
||||
const float width = 120f;
|
||||
const float height = 48f;
|
||||
Rect buttonRect = new Rect(bounds.width - width - 12f, 12f, width, height);
|
||||
if (GUI.Button(buttonRect, "DEBUG"))
|
||||
{
|
||||
_isPanelVisible = !_isPanelVisible;
|
||||
@@ -102,6 +144,12 @@ public class RuntimeDebugPanelComponent : MonoBehaviour
|
||||
}
|
||||
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("Runtime Debug", GUILayout.ExpandWidth(true));
|
||||
if (GUILayout.Button("Close", GUILayout.Width(90f))) _isPanelVisible = false;
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.Space(8f);
|
||||
_panelScroll = GUILayout.BeginScrollView(_panelScroll, false, true);
|
||||
|
||||
bool hasPreviousSection = false;
|
||||
if (_showBuffSection)
|
||||
@@ -130,20 +178,20 @@ public class RuntimeDebugPanelComponent : MonoBehaviour
|
||||
GUILayout.Space(8f);
|
||||
}
|
||||
|
||||
GUILayout.Label("Tips: press `F8` or tap top-left corner 3 times to toggle.", GUILayout.Height(20f));
|
||||
GUILayout.Label("Tips: press F8 or tap top-left corner 3 times to toggle.");
|
||||
}
|
||||
|
||||
GUILayout.EndScrollView();
|
||||
GUILayout.EndVertical();
|
||||
GUI.DragWindow(new Rect(0, 0, 10000, 22));
|
||||
}
|
||||
|
||||
private void DrawBuffSection()
|
||||
{
|
||||
GUILayout.Label("Buff Debug");
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("Search", GUILayout.Width(52f));
|
||||
GUILayout.Label("Search", GUILayout.Width(78f));
|
||||
_searchText = GUILayout.TextField(_searchText);
|
||||
if (GUILayout.Button("Refresh", GUILayout.Width(80f)))
|
||||
if (GUILayout.Button("Refresh", GUILayout.Width(100f)))
|
||||
{
|
||||
EnsurePropList(true);
|
||||
}
|
||||
@@ -169,12 +217,12 @@ public class RuntimeDebugPanelComponent : MonoBehaviour
|
||||
GUILayout.Label(ItemDescUtility.CreatePropDescription(selectedProp.Modifiers), GUILayout.Height(40f));
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("Count", GUILayout.Width(52f));
|
||||
string addCountText = GUILayout.TextField(_addCount.ToString(), GUILayout.Width(60f));
|
||||
GUILayout.Label("Count", GUILayout.Width(78f));
|
||||
string addCountText = GUILayout.TextField(_addCount.ToString(), GUILayout.Width(88f));
|
||||
if (!int.TryParse(addCountText, out _addCount)) _addCount = 1;
|
||||
_addCount = Mathf.Clamp(_addCount, 1, 99);
|
||||
|
||||
if (GUILayout.Button("Add Buff To Player", GUILayout.Height(24f)))
|
||||
if (GUILayout.Button("Add Buff To Player", GUILayout.Height(44f)))
|
||||
{
|
||||
AddSelectedBuffToPlayer(selectedProp, _addCount);
|
||||
}
|
||||
@@ -235,26 +283,31 @@ public class RuntimeDebugPanelComponent : MonoBehaviour
|
||||
|
||||
if (_showSpawnControls)
|
||||
{
|
||||
GUILayout.Space(12f);
|
||||
GUILayout.Label("Enemy Spawn Rate");
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("Rate", GUILayout.Width(52f));
|
||||
string rateText = GUILayout.TextField(_spawnRateScaleInput.ToString("F2"), GUILayout.Width(60f));
|
||||
GUILayout.Label("Rate", GUILayout.Width(78f));
|
||||
string rateText = GUILayout.TextField(_spawnRateScaleInput.ToString("F2"), GUILayout.Width(88f));
|
||||
if (float.TryParse(rateText, out float parsedRate))
|
||||
{
|
||||
_spawnRateScaleInput = Mathf.Clamp(parsedRate, MinSpawnRate, 50f);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Apply", GUILayout.Width(70f)))
|
||||
if (GUILayout.Button("Apply", GUILayout.Width(100f)))
|
||||
{
|
||||
enemyManager.SetSpawnRateScale(_spawnRateScaleInput);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("x0.5", GUILayout.Width(60f)))
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
if (GUILayout.Button("x0.5"))
|
||||
{
|
||||
_spawnRateScaleInput = Mathf.Max(MinSpawnRate, enemyManager.SpawnRateScale * 0.5f);
|
||||
enemyManager.SetSpawnRateScale(_spawnRateScaleInput);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("x2", GUILayout.Width(60f)))
|
||||
if (GUILayout.Button("x2"))
|
||||
{
|
||||
_spawnRateScaleInput = enemyManager.SpawnRateScale * 2f;
|
||||
enemyManager.SetSpawnRateScale(_spawnRateScaleInput);
|
||||
@@ -265,15 +318,17 @@ public class RuntimeDebugPanelComponent : MonoBehaviour
|
||||
|
||||
if (_showBattleDurationControls)
|
||||
{
|
||||
GUILayout.Space(12f);
|
||||
GUILayout.Label("Battle Duration");
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("Add Sec", GUILayout.Width(52f));
|
||||
string durationText = GUILayout.TextField(_extendDurationSeconds.ToString("F0"), GUILayout.Width(60f));
|
||||
GUILayout.Label("Add Sec", GUILayout.Width(78f));
|
||||
string durationText = GUILayout.TextField(_extendDurationSeconds.ToString("F0"), GUILayout.Width(88f));
|
||||
if (float.TryParse(durationText, out float parsedDuration))
|
||||
{
|
||||
_extendDurationSeconds = Mathf.Clamp(parsedDuration, 1f, 3600f);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Extend Battle", GUILayout.Height(24f)))
|
||||
if (GUILayout.Button("Extend Battle", GUILayout.Height(44f)))
|
||||
{
|
||||
if (procedure.CurrentGameState is GameStateBattle gameState)
|
||||
{
|
||||
@@ -286,16 +341,17 @@ public class RuntimeDebugPanelComponent : MonoBehaviour
|
||||
|
||||
if (_showPlayerWeaponControls)
|
||||
{
|
||||
GUILayout.Space(12f);
|
||||
GUILayout.Label(
|
||||
$"Player Weapon: {(player == null ? "Player not found" : (player.WeaponEnabled ? "Enabled" : "Disabled"))}");
|
||||
GUILayout.BeginHorizontal();
|
||||
GUI.enabled = player != null;
|
||||
if (GUILayout.Button("Disable Weapons", GUILayout.Height(24f)))
|
||||
if (GUILayout.Button("Disable Weapons", GUILayout.Height(44f)))
|
||||
{
|
||||
player.SetWeaponEnabled(false);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Enable Weapons", GUILayout.Height(24f)))
|
||||
if (GUILayout.Button("Enable Weapons", GUILayout.Height(44f)))
|
||||
{
|
||||
player.SetWeaponEnabled(true);
|
||||
}
|
||||
@@ -311,12 +367,12 @@ public class RuntimeDebugPanelComponent : MonoBehaviour
|
||||
$"Player HP: {(playerHealth == null ? "Unavailable" : $"{playerHealth.CurrentHealth}/{playerHealth.MaxHealth}")}");
|
||||
GUILayout.BeginHorizontal();
|
||||
GUI.enabled = playerHealth != null;
|
||||
if (GUILayout.Button($"+{DebugHealAmount} HP", GUILayout.Height(24f)))
|
||||
if (GUILayout.Button($"+{DebugHealAmount} HP", GUILayout.Height(44f)))
|
||||
{
|
||||
AddPlayerHealth(playerHealth, DebugHealAmount);
|
||||
}
|
||||
|
||||
if (GUILayout.Button(_lockPlayerHealthToMax ? "GodMode: ON" : "GodMode: OFF", GUILayout.Height(24f)))
|
||||
if (GUILayout.Button(_lockPlayerHealthToMax ? "GodMode: ON" : "GodMode: OFF", GUILayout.Height(44f)))
|
||||
{
|
||||
_lockPlayerHealthToMax = !_lockPlayerHealthToMax;
|
||||
if (_lockPlayerHealthToMax)
|
||||
@@ -525,5 +581,3 @@ public class RuntimeDebugPanelComponent : MonoBehaviour
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user