【debug】增加强制进入关卡

main
刘涛 2025-05-07 14:28:05 +08:00
parent 8c7a4cba9a
commit bc53bc0a5a
9 changed files with 147 additions and 0 deletions

View File

@ -0,0 +1,32 @@
namespace FightDebug
{
public abstract class BaseSubDebugPanel : ISubDebugPanel
{
public bool isFold
{
get;
set;
}
public string title
{
get;
}
public BaseSubDebugPanel(string setTitle)
{
title = setTitle;
}
public void DrawUI()
{
_OnDrawUI();
}
protected virtual void _OnDrawUI()
{
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 96918301128746309c668b27cf5092d5
timeCreated: 1746596478

View File

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using FightDebug.Impl;
using UnityEngine;
using UnityEditor;
namespace FightDebug
{
public class FightDebugWindowV3 : EditorWindow
{
[MenuItem("Tools/*战斗信息Debug/FightDebugWindowV3 _F10")]
public static void ShowWindow()
{
var window = GetWindow<FightDebugWindowV3>();
window._AddSubPanel(new Debug_ForceEnterLevel());
window.titleContent = new GUIContent("战斗信息修改");
window.Show();
}
private List<ISubDebugPanel> _subDebugWindows = new List<ISubDebugPanel>();
private void _AddSubPanel(ISubDebugPanel subPanel)
{
_subDebugWindows.Add(subPanel);
}
private void OnGUI()
{
for (int i = 0; i < _subDebugWindows.Count; i++)
{
var subDebugWindow = _subDebugWindows[i];
subDebugWindow.isFold = EditorGUILayout.Foldout(subDebugWindow.isFold, subDebugWindow.title);
if (subDebugWindow.isFold)
{
subDebugWindow.DrawUI();
}
}
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e9f464fc51e8405f900dc5c186beedc1
timeCreated: 1746596158

View File

@ -0,0 +1,9 @@
namespace FightDebug
{
public interface ISubDebugPanel
{
bool isFold { get; set; }
string title { get; }
void DrawUI();
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 469e8c3a2418447db868c20a9a6ec37c
timeCreated: 1746596415

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f181937cf49a4eda8d04e83ea5e94c40
timeCreated: 1746596333

View File

@ -0,0 +1,51 @@
using cfg.LevelCfg;
using Framework;
using Gameplay.Level;
using UnityEditor;
using UnityEngine;
namespace FightDebug.Impl
{
public class Debug_ForceEnterLevel : BaseSubDebugPanel
{
private int _levelId;
private DataLevel _levelConfig;
public Debug_ForceEnterLevel() : base("强制进入关卡")
{
}
protected override void _OnDrawUI()
{
base._OnDrawUI();
GUILayout.BeginHorizontal();
GUILayout.Label("关卡ID", GUILayout.Width(60));
var newLevelId = EditorGUILayout.IntField(_levelId, GUILayout.Width(200));
if (newLevelId != _levelId)
{
_levelId = newLevelId;
_levelConfig = EditorTableManager.instance.tables.Level.GetOrDefault(newLevelId);
if (_levelConfig == null)
{
EditorGUILayout.HelpBox("无效的关卡ID", MessageType.Error);
}
}
GUILayout.EndHorizontal();
if (GUILayout.Button("进入关卡", GUILayout.Height(40)))
{
if (_levelConfig == null)
{
_levelConfig = EditorTableManager.instance.tables.Level.GetOrDefault(newLevelId);
}
if (_levelConfig == null)
{
// 弹出对话框提示
EditorUtility.DisplayDialog("错误", "无效的关卡ID", "确定");
return;
}
LevelManager.Instance.EnterLevelDirectly(_levelId);
}
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 32f5457b169e462ca08b977d0e67ba32
timeCreated: 1746596384