继续
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#if UNITY_EDITOR
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using SLSFramework.UModAssistance;
|
||||
@@ -10,7 +11,25 @@ namespace Continentis.MainGame.Card
|
||||
public class CardDataEditor : DataEditor
|
||||
{
|
||||
// 存储我们需要自定义绘制的属性的引用
|
||||
private SerializedProperty classFullNameProp;
|
||||
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;
|
||||
|
||||
private SerializedProperty prefabsProp;
|
||||
private SerializedProperty derivativeCardsProp;
|
||||
private SerializedProperty derivativeCharactersProp;
|
||||
@@ -20,7 +39,20 @@ namespace Continentis.MainGame.Card
|
||||
base.OnEnable();
|
||||
|
||||
// 在启用时,根据我们修改后的字段名找到对应的SerializedProperty
|
||||
classFullNameProp = serializedObject.FindProperty("classFullName");
|
||||
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");
|
||||
prefabsProp = serializedObject.FindProperty("prefabRefs");
|
||||
derivativeCardsProp = serializedObject.FindProperty("derivativeCardDataRefs");
|
||||
derivativeCharactersProp = serializedObject.FindProperty("derivativeCharacterDataRefs");
|
||||
@@ -33,30 +65,42 @@ namespace Continentis.MainGame.Card
|
||||
// --- 绘制自定义的Type选择器 ---
|
||||
// 我们把它从所有自动绘制的属性中分离出来,放在最前面或最后面,让布局更清晰
|
||||
EditorGUILayout.Space(); // 增加一点间距
|
||||
EditorGUILayout.LabelField("Logic", EditorStyles.boldLabel);
|
||||
if (DrawTypeSelectorGUI(classFullNameProp, "Card Logic Class", typeof(CardLogicBase), "Continentis.Mods", "Cards"))
|
||||
EditorGUILayout.LabelField("Fundamental", EditorStyles.boldLabel);
|
||||
if (DrawTypeSelectorGUI(classNameProp, "Card Logic Class", typeof(CardLogicBase), out Type outType, "Continentis.Mods", "Cards"))
|
||||
{
|
||||
string classFullName = classFullNameProp.stringValue;
|
||||
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";
|
||||
|
||||
string displayName = "Card_" + classFullName + "_DisplayName";
|
||||
SerializedProperty displayNameProp = serializedObject.FindProperty("displayName");
|
||||
modNameProp.stringValue = modName;
|
||||
displayNameProp.stringValue = displayName;
|
||||
|
||||
string functionTextName = "Card_" + classFullName + "_FunctionText";
|
||||
SerializedProperty functionTextProp = serializedObject.FindProperty("functionText");
|
||||
functionTextProp.stringValue = functionTextName;
|
||||
}
|
||||
|
||||
// --- 核心修复 2:将 _cardLogicClassNameProp 也加入排除列表 ---
|
||||
// 因为这也是我们手动绘制的
|
||||
DrawPropertiesExcluding(serializedObject, new string[]
|
||||
{
|
||||
"m_Script",
|
||||
classFullNameProp.name, // <-- 新增
|
||||
prefabsProp.name,
|
||||
derivativeCardsProp.name,
|
||||
derivativeCharactersProp.name
|
||||
});
|
||||
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);
|
||||
|
||||
// --- 绘制自定义的引用列表 ---
|
||||
EditorGUILayout.Space();
|
||||
|
||||
Reference in New Issue
Block a user