卡牌更新
This commit is contained in:
@@ -205,6 +205,54 @@ namespace Continentis.MainGame.Card
|
||||
}
|
||||
|
||||
|
||||
[BoxGroup("Fundamental")]
|
||||
[PropertyOrder(6)]
|
||||
[Button("📄 打开逻辑脚本", ButtonSizes.Medium)]
|
||||
[GUIColor(1f, 0.92f, 0.6f)]
|
||||
[ShowIf("@!string.IsNullOrEmpty(className)")]
|
||||
private void OpenCardLogicScript()
|
||||
{
|
||||
if (string.IsNullOrEmpty(className))
|
||||
{
|
||||
Debug.LogWarning("[CardData] 尚未选择逻辑类,无法打开对应脚本。");
|
||||
return;
|
||||
}
|
||||
|
||||
// 根据 modName / categoryName / className 拼接可能的文件路径
|
||||
// 路径格式: Assets/Mods/{modName}/Cards/Scripts/{categoryName}/{className}.cs
|
||||
// | Assets/Mods/{modName}/Cards/Scripts/{className}.cs (无分类时)
|
||||
var candidatePaths = new List<string>();
|
||||
|
||||
if (!string.IsNullOrEmpty(categoryName))
|
||||
candidatePaths.Add($"Assets/Mods/{modName}/Cards/Scripts/{categoryName}/{className}.cs");
|
||||
|
||||
candidatePaths.Add($"Assets/Mods/{modName}/Cards/Scripts/{className}.cs");
|
||||
|
||||
// 在全项目中也搜一遍(应对目录结构不规范的情况)
|
||||
string[] guids = AssetDatabase.FindAssets($"{className} t:MonoScript");
|
||||
foreach (string guid in guids)
|
||||
{
|
||||
string p = AssetDatabase.GUIDToAssetPath(guid);
|
||||
if (Path.GetFileNameWithoutExtension(p) == className)
|
||||
candidatePaths.Add(p);
|
||||
}
|
||||
|
||||
foreach (string path in candidatePaths)
|
||||
{
|
||||
var script = AssetDatabase.LoadAssetAtPath<UnityEditor.MonoScript>(path);
|
||||
if (script != null)
|
||||
{
|
||||
AssetDatabase.OpenAsset(script);
|
||||
EditorGUIUtility.PingObject(script);
|
||||
Debug.Log($"[CardData] 已打开逻辑脚本:{path}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.LogError($"[CardData] 未找到逻辑类 '{className}' 对应的脚本文件。\n" +
|
||||
$"已搜索路径:\n{string.Join("\n", candidatePaths)}");
|
||||
}
|
||||
|
||||
[BoxGroup("Display")]
|
||||
[PropertyOrder(11)]
|
||||
[Button("✨ 预览卡牌效果", ButtonSizes.Medium)]
|
||||
|
||||
Reference in New Issue
Block a user