2025-10-23 00:49:44 -04:00
|
|
|
|
#if UNITY_EDITOR
|
2025-10-24 09:11:22 -04:00
|
|
|
|
using System;
|
2025-10-27 07:04:34 -04:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
2025-10-23 00:49:44 -04:00
|
|
|
|
using UnityEditor;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using SLSFramework.UModAssistance;
|
|
|
|
|
|
using Continentis.MainGame.Character;
|
2025-10-27 07:04:34 -04:00
|
|
|
|
using Continentis.Mods;
|
2025-10-23 00:49:44 -04:00
|
|
|
|
|
|
|
|
|
|
namespace Continentis.MainGame.Card
|
|
|
|
|
|
{
|
|
|
|
|
|
[CustomEditor(typeof(CardData))]
|
2025-10-27 07:04:34 -04:00
|
|
|
|
public partial class CardDataEditor : DataEditor
|
2025-10-23 00:49:44 -04:00
|
|
|
|
{
|
|
|
|
|
|
// 存储我们需要自定义绘制的属性的引用
|
2025-10-24 09:11:22 -04:00
|
|
|
|
private SerializedProperty modNameProp;
|
2025-11-10 11:18:19 -05:00
|
|
|
|
private SerializedProperty categoryNameProp;
|
2025-10-24 09:11:22 -04:00
|
|
|
|
private SerializedProperty classNameProp;
|
|
|
|
|
|
private SerializedProperty displayNameProp;
|
|
|
|
|
|
private SerializedProperty cardRarityProp;
|
|
|
|
|
|
private SerializedProperty cardTypeProp;
|
2025-10-27 07:04:34 -04:00
|
|
|
|
private SerializedProperty keywordsProp;
|
2025-10-24 09:11:22 -04:00
|
|
|
|
|
|
|
|
|
|
private SerializedProperty cardSpriteProp;
|
2025-10-27 07:04:34 -04:00
|
|
|
|
private SerializedProperty cardLayoutTagsProp;
|
2025-10-24 09:11:22 -04:00
|
|
|
|
private SerializedProperty functionTextProp;
|
|
|
|
|
|
private SerializedProperty cardDescriptionProp;
|
|
|
|
|
|
|
2025-11-30 14:21:08 -05:00
|
|
|
|
private SerializedProperty intentionIconKeysProp;
|
|
|
|
|
|
private SerializedProperty intentionValueNamesProp;
|
2025-11-30 21:22:39 -05:00
|
|
|
|
private SerializedProperty intentionTextOverrideProp;
|
2025-10-24 09:11:22 -04:00
|
|
|
|
private SerializedProperty baseWeightProp;
|
|
|
|
|
|
|
2025-11-30 14:21:08 -05:00
|
|
|
|
|
2025-10-24 09:11:22 -04:00
|
|
|
|
private SerializedProperty variableAttributesProp;
|
|
|
|
|
|
private SerializedProperty originalAttributesProp;
|
|
|
|
|
|
private SerializedProperty runtimeCurrentAttributesProp;
|
|
|
|
|
|
|
|
|
|
|
|
private SerializedProperty upgradeNodeProp;
|
|
|
|
|
|
|
2025-10-23 00:49:44 -04:00
|
|
|
|
private SerializedProperty prefabsProp;
|
|
|
|
|
|
private SerializedProperty derivativeCardsProp;
|
|
|
|
|
|
private SerializedProperty derivativeCharactersProp;
|
2025-10-27 07:04:34 -04:00
|
|
|
|
|
2025-10-23 00:49:44 -04:00
|
|
|
|
protected override void OnEnable()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnEnable();
|
|
|
|
|
|
// 在启用时,根据我们修改后的字段名找到对应的SerializedProperty
|
2025-10-24 09:11:22 -04:00
|
|
|
|
modNameProp = serializedObject.FindProperty("modName");
|
|
|
|
|
|
classNameProp = serializedObject.FindProperty("className");
|
2025-11-10 11:18:19 -05:00
|
|
|
|
categoryNameProp = serializedObject.FindProperty("categoryName");
|
2025-10-24 09:11:22 -04:00
|
|
|
|
displayNameProp = serializedObject.FindProperty("displayName");
|
|
|
|
|
|
cardRarityProp = serializedObject.FindProperty("cardRarity");
|
|
|
|
|
|
cardTypeProp = serializedObject.FindProperty("cardType");
|
2025-10-27 07:04:34 -04:00
|
|
|
|
keywordsProp = serializedObject.FindProperty("keywords");
|
2025-10-24 09:11:22 -04:00
|
|
|
|
cardSpriteProp = serializedObject.FindProperty("cardSprite");
|
2025-10-27 07:04:34 -04:00
|
|
|
|
cardLayoutTagsProp = serializedObject.FindProperty("cardLayoutTags");
|
2025-10-24 09:11:22 -04:00
|
|
|
|
functionTextProp = serializedObject.FindProperty("functionText");
|
|
|
|
|
|
cardDescriptionProp = serializedObject.FindProperty("cardDescription");
|
2025-11-30 14:21:08 -05:00
|
|
|
|
|
|
|
|
|
|
intentionIconKeysProp = serializedObject.FindProperty("intentionIconKeys");
|
|
|
|
|
|
intentionValueNamesProp = serializedObject.FindProperty("intentionValueNames");
|
2025-11-30 21:22:39 -05:00
|
|
|
|
intentionTextOverrideProp = serializedObject.FindProperty("intentionTextOverride");
|
2025-10-24 09:11:22 -04:00
|
|
|
|
baseWeightProp = serializedObject.FindProperty("baseWeight");
|
2025-11-30 14:21:08 -05:00
|
|
|
|
|
2025-10-24 09:11:22 -04:00
|
|
|
|
variableAttributesProp = serializedObject.FindProperty("variableAttributes");
|
|
|
|
|
|
originalAttributesProp = serializedObject.FindProperty("originalAttributes");
|
|
|
|
|
|
runtimeCurrentAttributesProp = serializedObject.FindProperty("runtimeCurrentAttributes");
|
|
|
|
|
|
upgradeNodeProp = serializedObject.FindProperty("upgradeNode");
|
2025-10-23 00:49:44 -04:00
|
|
|
|
prefabsProp = serializedObject.FindProperty("prefabRefs");
|
|
|
|
|
|
derivativeCardsProp = serializedObject.FindProperty("derivativeCardDataRefs");
|
|
|
|
|
|
derivativeCharactersProp = serializedObject.FindProperty("derivativeCharacterDataRefs");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnInspectorGUI()
|
|
|
|
|
|
{
|
|
|
|
|
|
serializedObject.Update();
|
|
|
|
|
|
|
|
|
|
|
|
// --- 绘制自定义的Type选择器 ---
|
|
|
|
|
|
// 我们把它从所有自动绘制的属性中分离出来,放在最前面或最后面,让布局更清晰
|
|
|
|
|
|
EditorGUILayout.Space(); // 增加一点间距
|
2025-10-24 09:11:22 -04:00
|
|
|
|
EditorGUILayout.LabelField("Fundamental", EditorStyles.boldLabel);
|
2025-11-10 11:18:19 -05:00
|
|
|
|
|
|
|
|
|
|
DrawSearchableTypeSelector(
|
|
|
|
|
|
classNameProp, // 1. 存储类名的字符串属性
|
|
|
|
|
|
"Card Logic Class", // 2. 显示的标签
|
|
|
|
|
|
typeof(CardLogicBase), // 3. 要搜索的基类
|
|
|
|
|
|
(outType) => // 4. 【关键】当用户选择后执行的回调
|
|
|
|
|
|
{
|
|
|
|
|
|
string className = outType.Name;
|
|
|
|
|
|
string modName = outType.Namespace!.Replace("Continentis.Mods.", "").Split('.')[0];
|
|
|
|
|
|
string categoryName = outType.Namespace!.Replace("Continentis.Mods." + modName + ".Cards", "");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(categoryName))
|
|
|
|
|
|
{
|
|
|
|
|
|
categoryName = outType.Namespace!.Replace("Continentis.Mods." + modName + ".Cards", "").Substring(1); // 去掉开头的点
|
|
|
|
|
|
}
|
|
|
|
|
|
string displayName = "Card_" + modName + "_" + className + "_DisplayName";
|
|
|
|
|
|
string functionTextName = "Card_" + modName + "_" + className + "_FunctionText";
|
2025-10-23 00:49:44 -04:00
|
|
|
|
|
2025-11-10 11:18:19 -05:00
|
|
|
|
classNameProp.stringValue = className;
|
|
|
|
|
|
modNameProp.stringValue = modName;
|
|
|
|
|
|
categoryNameProp.stringValue = categoryName;
|
|
|
|
|
|
displayNameProp.stringValue = displayName;
|
|
|
|
|
|
functionTextProp.stringValue = functionTextName;
|
|
|
|
|
|
|
|
|
|
|
|
Debug.Log(outType.FullName);
|
|
|
|
|
|
Debug.Log($"modName: {modName}, categoryName: {categoryName}, className: {className}, displayName: {displayName}, functionText: {functionTextName}");
|
|
|
|
|
|
|
|
|
|
|
|
serializedObject.ApplyModifiedProperties();
|
|
|
|
|
|
},
|
|
|
|
|
|
"Continentis.Mods", // 5. 你的 namespacePrefix
|
|
|
|
|
|
"Cards" // 6. 你的 namespaceToRemove (注意:根据你的代码,这里不应包含".")
|
|
|
|
|
|
);
|
2025-10-23 00:49:44 -04:00
|
|
|
|
|
2025-10-24 09:11:22 -04:00
|
|
|
|
EditorGUI.BeginDisabledGroup(true);
|
|
|
|
|
|
EditorGUILayout.PropertyField(modNameProp);
|
2025-11-10 11:18:19 -05:00
|
|
|
|
EditorGUILayout.PropertyField(categoryNameProp);
|
2025-10-24 09:11:22 -04:00
|
|
|
|
EditorGUILayout.PropertyField(classNameProp);
|
|
|
|
|
|
EditorGUILayout.PropertyField(displayNameProp);
|
|
|
|
|
|
EditorGUI.EndDisabledGroup();
|
|
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.PropertyField(cardRarityProp);
|
|
|
|
|
|
EditorGUILayout.PropertyField(cardTypeProp);
|
2025-11-30 14:21:08 -05:00
|
|
|
|
DrawListWithEditRefSelector(keywordsProp, "CardKeywords");
|
2025-10-27 07:04:34 -04:00
|
|
|
|
|
2025-10-24 09:11:22 -04:00
|
|
|
|
EditorGUILayout.PropertyField(cardSpriteProp);
|
2025-10-27 07:04:34 -04:00
|
|
|
|
EditorGUILayout.PropertyField(cardLayoutTagsProp, true);
|
2025-10-24 09:11:22 -04:00
|
|
|
|
EditorGUILayout.PropertyField(functionTextProp);
|
|
|
|
|
|
EditorGUILayout.PropertyField(cardDescriptionProp);
|
|
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
|
|
EditorGUILayout.LabelField("Attributes", EditorStyles.boldLabel);
|
2025-11-30 14:21:08 -05:00
|
|
|
|
DrawListWithEditRefSelector(intentionIconKeysProp, "IntentionIconKeys");
|
|
|
|
|
|
DrawListWithLocalSelector(intentionValueNamesProp, "variableAttributes");
|
2025-11-30 21:22:39 -05:00
|
|
|
|
EditorGUILayout.PropertyField(intentionTextOverrideProp);
|
2025-10-24 09:11:22 -04:00
|
|
|
|
EditorGUILayout.PropertyField(baseWeightProp);
|
|
|
|
|
|
EditorGUILayout.PropertyField(variableAttributesProp, true);
|
|
|
|
|
|
EditorGUILayout.PropertyField(originalAttributesProp, true);
|
|
|
|
|
|
EditorGUILayout.PropertyField(runtimeCurrentAttributesProp, true);
|
|
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
|
|
EditorGUILayout.LabelField("Upgrade", EditorStyles.boldLabel);
|
|
|
|
|
|
EditorGUILayout.PropertyField(upgradeNodeProp);
|
2025-10-23 00:49:44 -04:00
|
|
|
|
|
|
|
|
|
|
// --- 绘制自定义的引用列表 ---
|
|
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
|
|
EditorGUILayout.LabelField("References", EditorStyles.boldLabel);
|
|
|
|
|
|
DrawCharacterListGUI<GameObject>(prefabsProp);
|
|
|
|
|
|
DrawCharacterListGUI<CardData>(derivativeCardsProp);
|
|
|
|
|
|
DrawCharacterListGUI<CharacterData>(derivativeCharactersProp);
|
|
|
|
|
|
|
|
|
|
|
|
HandleObjectPicker();
|
|
|
|
|
|
|
|
|
|
|
|
serializedObject.ApplyModifiedProperties();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|