MOD!
This commit is contained in:
74
Assets/Scripts/MainGame/Card/Editor/CardDataEditor.cs
Normal file
74
Assets/Scripts/MainGame/Card/Editor/CardDataEditor.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using SLSFramework.UModAssistance;
|
||||
using Continentis.MainGame.Character;
|
||||
|
||||
namespace Continentis.MainGame.Card
|
||||
{
|
||||
[CustomEditor(typeof(CardData))]
|
||||
public class CardDataEditor : DataEditor
|
||||
{
|
||||
// 存储我们需要自定义绘制的属性的引用
|
||||
private SerializedProperty classFullNameProp;
|
||||
private SerializedProperty prefabsProp;
|
||||
private SerializedProperty derivativeCardsProp;
|
||||
private SerializedProperty derivativeCharactersProp;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
|
||||
// 在启用时,根据我们修改后的字段名找到对应的SerializedProperty
|
||||
classFullNameProp = serializedObject.FindProperty("classFullName");
|
||||
prefabsProp = serializedObject.FindProperty("prefabRefs");
|
||||
derivativeCardsProp = serializedObject.FindProperty("derivativeCardDataRefs");
|
||||
derivativeCharactersProp = serializedObject.FindProperty("derivativeCharacterDataRefs");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
// --- 绘制自定义的Type选择器 ---
|
||||
// 我们把它从所有自动绘制的属性中分离出来,放在最前面或最后面,让布局更清晰
|
||||
EditorGUILayout.Space(); // 增加一点间距
|
||||
EditorGUILayout.LabelField("Logic", EditorStyles.boldLabel);
|
||||
if (DrawTypeSelectorGUI(classFullNameProp, "Card Logic Class", typeof(CardLogicBase), "Continentis.Mods", "Cards"))
|
||||
{
|
||||
string classFullName = classFullNameProp.stringValue;
|
||||
|
||||
string displayName = "Card_" + classFullName + "_DisplayName";
|
||||
SerializedProperty displayNameProp = serializedObject.FindProperty("displayName");
|
||||
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
|
||||
});
|
||||
|
||||
// --- 绘制自定义的引用列表 ---
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("References", EditorStyles.boldLabel);
|
||||
DrawCharacterListGUI<GameObject>(prefabsProp);
|
||||
DrawCharacterListGUI<CardData>(derivativeCardsProp);
|
||||
DrawCharacterListGUI<CharacterData>(derivativeCharactersProp);
|
||||
|
||||
HandleObjectPicker();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8385aa085e0e6154da49b54bdc5d26e7
|
||||
Reference in New Issue
Block a user