127 lines
5.9 KiB
C#
127 lines
5.9 KiB
C#
#if UNITY_EDITOR
|
||
using UnityEditor;
|
||
using UnityEngine;
|
||
using Continentis.MainGame.Card;
|
||
using Continentis.MainGame.UI;
|
||
using SLSFramework.UModAssistance;
|
||
|
||
namespace Continentis.MainGame.Character
|
||
{
|
||
[CustomEditor(typeof(CharacterData))]
|
||
public class CharacterDataEditor : DataEditor
|
||
{
|
||
// --- 存储所有字段的 SerializedProperty 引用 ---
|
||
// Fundamental
|
||
private SerializedProperty _haveCustomClassProp;
|
||
private SerializedProperty _classFullNameProp;
|
||
private SerializedProperty _modNameProp;
|
||
private SerializedProperty _classNameProp;
|
||
private SerializedProperty _displayNameProp;
|
||
private SerializedProperty _avatarProp;
|
||
private SerializedProperty _portraitProp;
|
||
private SerializedProperty _characterDescriptionProp;
|
||
private SerializedProperty _tagsProp;
|
||
|
||
// Attributes
|
||
private SerializedProperty _coreAttributesProp;
|
||
private SerializedProperty _generalAttributesProp;
|
||
private SerializedProperty _runtimeGeneralAttributesProp;
|
||
|
||
// View
|
||
private SerializedProperty _combatPositionOrderProp;
|
||
private SerializedProperty _combatCharacterViewProp;
|
||
private SerializedProperty _animationsProp;
|
||
|
||
// Deck & References
|
||
private SerializedProperty _initialDeckRefsProp;
|
||
private SerializedProperty _prefabRefsProp;
|
||
private SerializedProperty _derivativeCardDataRefsProp;
|
||
private SerializedProperty _derivativeCharacterDataRefsProp;
|
||
private SerializedProperty _hudDataRefsProp;
|
||
|
||
protected override void OnEnable()
|
||
{
|
||
base.OnEnable();
|
||
// --- 在OnEnable中找到所有属性 ---
|
||
_haveCustomClassProp = serializedObject.FindProperty("haveCustomClass");
|
||
_classFullNameProp = serializedObject.FindProperty("classFullName");
|
||
_modNameProp = serializedObject.FindProperty("modName");
|
||
_classNameProp = serializedObject.FindProperty("className");
|
||
_displayNameProp = serializedObject.FindProperty("displayName");
|
||
_avatarProp = serializedObject.FindProperty("avatar");
|
||
_portraitProp = serializedObject.FindProperty("portrait");
|
||
_characterDescriptionProp = serializedObject.FindProperty("characterDescription");
|
||
_tagsProp = serializedObject.FindProperty("tags");
|
||
|
||
_coreAttributesProp = serializedObject.FindProperty("coreAttributes");
|
||
_generalAttributesProp = serializedObject.FindProperty("generalAttributes");
|
||
_runtimeGeneralAttributesProp = serializedObject.FindProperty("runtimeGeneralAttributes");
|
||
|
||
_combatPositionOrderProp = serializedObject.FindProperty("combatPositionOrder");
|
||
_combatCharacterViewProp = serializedObject.FindProperty("combatCharacterView");
|
||
_animationsProp = serializedObject.FindProperty("animations");
|
||
|
||
_initialDeckRefsProp = serializedObject.FindProperty("initialDeckRef");
|
||
_prefabRefsProp = serializedObject.FindProperty("prefabRefs");
|
||
_derivativeCardDataRefsProp = serializedObject.FindProperty("derivativeCardDataRefs");
|
||
_derivativeCharacterDataRefsProp = serializedObject.FindProperty("derivativeCharacterDataRefs");
|
||
_hudDataRefsProp = serializedObject.FindProperty("hudDataRefs");
|
||
}
|
||
|
||
public override void OnInspectorGUI()
|
||
{
|
||
serializedObject.Update();
|
||
|
||
// --- 按照你在CharacterData.cs中声明的顺序手动绘制所有字段 ---
|
||
EditorGUILayout.PropertyField(_haveCustomClassProp);
|
||
|
||
// --- 核心逻辑:根据 haveCustomClass 的值来决定显示/隐藏 ---
|
||
if (_haveCustomClassProp.boolValue)
|
||
{
|
||
// 如果勾选,则显示class选择器
|
||
DrawSearchableTypeSelector(_classFullNameProp, "Character Logic Class", typeof(CharacterLogicBase), null, "Continentis.Mods", "Characters");
|
||
}
|
||
else
|
||
{
|
||
// 如果不勾选,则显示modName和characterName
|
||
EditorGUILayout.PropertyField(_modNameProp);
|
||
EditorGUILayout.PropertyField(_classNameProp);
|
||
}
|
||
|
||
EditorGUILayout.PropertyField(_displayNameProp);
|
||
EditorGUILayout.PropertyField(_avatarProp);
|
||
EditorGUILayout.PropertyField(_portraitProp);
|
||
EditorGUILayout.PropertyField(_characterDescriptionProp);
|
||
EditorGUILayout.PropertyField(_tagsProp, true); // true 表示绘制列表的全部内容
|
||
|
||
EditorGUILayout.Space();
|
||
EditorGUILayout.PropertyField(_coreAttributesProp, true);
|
||
EditorGUILayout.PropertyField(_generalAttributesProp, true);
|
||
EditorGUILayout.PropertyField(_runtimeGeneralAttributesProp, true);
|
||
|
||
EditorGUILayout.Space();
|
||
EditorGUILayout.PropertyField(_combatPositionOrderProp);
|
||
EditorGUILayout.PropertyField(_combatCharacterViewProp);
|
||
EditorGUILayout.PropertyField(_animationsProp, true);
|
||
|
||
EditorGUILayout.Space();
|
||
EditorGUILayout.LabelField("References", EditorStyles.boldLabel);
|
||
DrawCharacterListGUI<GameObject>(_prefabRefsProp);
|
||
DrawCharacterListGUI<CardData>(_derivativeCardDataRefsProp);
|
||
DrawCharacterListGUI<CharacterData>(_derivativeCharacterDataRefsProp);
|
||
DrawCharacterListGUI<CardData>(_initialDeckRefsProp);
|
||
DrawCharacterListGUI<HUDData>(_hudDataRefsProp);
|
||
|
||
// 处理所有可能发生的ObjectPicker事件
|
||
HandleObjectPicker();
|
||
|
||
EditorGUILayout.Space();
|
||
EditorGUILayout.LabelField("Functions", EditorStyles.boldLabel);
|
||
DrawMethodButton<CharacterData>("Paste Default Attributes", "PasteDefaultAttributes");
|
||
|
||
serializedObject.ApplyModifiedProperties();
|
||
}
|
||
}
|
||
}
|
||
|
||
#endif |