2025-10-23 00:49:44 -04:00
|
|
|
|
#if UNITY_EDITOR
|
2025-10-24 09:11:22 -04:00
|
|
|
|
using System;
|
2025-10-23 00:49:44 -04:00
|
|
|
|
using UnityEditor;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using SLSFramework.UModAssistance;
|
|
|
|
|
|
using Continentis.MainGame.Character;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Continentis.MainGame.Card
|
|
|
|
|
|
{
|
|
|
|
|
|
[CustomEditor(typeof(CardData))]
|
|
|
|
|
|
public class CardDataEditor : DataEditor
|
|
|
|
|
|
{
|
|
|
|
|
|
// 存储我们需要自定义绘制的属性的引用
|
2025-10-24 09:11:22 -04:00
|
|
|
|
private SerializedProperty modNameProp;
|
|
|
|
|
|
private SerializedProperty classNameProp;
|
|
|
|
|
|
private SerializedProperty displayNameProp;
|
|
|
|
|
|
private SerializedProperty cardRarityProp;
|
|
|
|
|
|
private SerializedProperty cardTypeProp;
|
|
|
|
|
|
private SerializedProperty tagsProp;
|
|
|
|
|
|
|
|
|
|
|
|
private SerializedProperty cardSpriteProp;
|
|
|
|
|
|
private SerializedProperty functionTextProp;
|
|
|
|
|
|
private SerializedProperty cardDescriptionProp;
|
|
|
|
|
|
|
|
|
|
|
|
private SerializedProperty baseWeightProp;
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnEnable()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnEnable();
|
|
|
|
|
|
|
|
|
|
|
|
// 在启用时,根据我们修改后的字段名找到对应的SerializedProperty
|
2025-10-24 09:11:22 -04:00
|
|
|
|
modNameProp = serializedObject.FindProperty("modName");
|
|
|
|
|
|
classNameProp = serializedObject.FindProperty("className");
|
|
|
|
|
|
displayNameProp = serializedObject.FindProperty("displayName");
|
|
|
|
|
|
cardRarityProp = serializedObject.FindProperty("cardRarity");
|
|
|
|
|
|
cardTypeProp = serializedObject.FindProperty("cardType");
|
|
|
|
|
|
tagsProp = serializedObject.FindProperty("tags");
|
|
|
|
|
|
cardSpriteProp = serializedObject.FindProperty("cardSprite");
|
|
|
|
|
|
functionTextProp = serializedObject.FindProperty("functionText");
|
|
|
|
|
|
cardDescriptionProp = serializedObject.FindProperty("cardDescription");
|
|
|
|
|
|
baseWeightProp = serializedObject.FindProperty("baseWeight");
|
|
|
|
|
|
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);
|
|
|
|
|
|
if (DrawTypeSelectorGUI(classNameProp, "Card Logic Class", typeof(CardLogicBase), out Type outType, "Continentis.Mods", "Cards"))
|
2025-10-23 00:49:44 -04:00
|
|
|
|
{
|
2025-10-24 09:11:22 -04:00
|
|
|
|
string className = classNameProp.stringValue;
|
|
|
|
|
|
string modName = outType.Namespace!.Replace("Continentis.Mods.", "").Split('.')[0];
|
|
|
|
|
|
string displayName = "Card_" + modName + "_" + className + "_DisplayName";
|
|
|
|
|
|
string functionTextName = "Card_" + modName + "_" + className + "_FunctionText";
|
2025-10-23 00:49:44 -04:00
|
|
|
|
|
2025-10-24 09:11:22 -04:00
|
|
|
|
modNameProp.stringValue = modName;
|
2025-10-23 00:49:44 -04:00
|
|
|
|
displayNameProp.stringValue = displayName;
|
|
|
|
|
|
functionTextProp.stringValue = functionTextName;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-24 09:11:22 -04:00
|
|
|
|
EditorGUI.BeginDisabledGroup(true);
|
|
|
|
|
|
EditorGUILayout.PropertyField(modNameProp);
|
|
|
|
|
|
EditorGUILayout.PropertyField(classNameProp);
|
|
|
|
|
|
EditorGUILayout.PropertyField(displayNameProp);
|
|
|
|
|
|
EditorGUI.EndDisabledGroup();
|
|
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.PropertyField(cardRarityProp);
|
|
|
|
|
|
EditorGUILayout.PropertyField(cardTypeProp);
|
|
|
|
|
|
EditorGUILayout.PropertyField(tagsProp, true);
|
|
|
|
|
|
EditorGUILayout.PropertyField(cardSpriteProp);
|
|
|
|
|
|
EditorGUILayout.PropertyField(functionTextProp);
|
|
|
|
|
|
EditorGUILayout.PropertyField(cardDescriptionProp);
|
|
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
|
|
EditorGUILayout.LabelField("Attributes", EditorStyles.boldLabel);
|
|
|
|
|
|
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
|