Files
Continentis/Assets/Scripts/MainGame/Equipment/Editor/EquipmentDataEditor.cs
SoulliesOfficial 76157e3cb1 继续
2025-10-24 09:11:22 -04:00

127 lines
6.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#if UNITY_EDITOR
using System;
using UnityEditor;
using UnityEngine;
using Continentis.MainGame.Card;
using Continentis.MainGame.Character;
using SLSFramework.UModAssistance;
namespace Continentis.MainGame.Equipment
{
[CustomEditor(typeof(EquipmentData))]
public class EquipmentDataEditor : DataEditor
{
// Fundamental
private SerializedProperty _haveCustomClassProp;
private SerializedProperty _modNameProp;
private SerializedProperty _classNameProp;
private SerializedProperty _displayNameProp;
private SerializedProperty _tagsProp;
private SerializedProperty _equipmentRarityProp;
private SerializedProperty _equipmentIconProp;
private SerializedProperty _equipmentDescriptionProp;
// Attributes
private SerializedProperty _coreNumericChangeProp;
private SerializedProperty _corePercentageChangeOfAccumulationProp;
private SerializedProperty _corePercentageChangeOfMultiplicationProp;
private SerializedProperty _generalNumericChangeProp;
private SerializedProperty _generalPercentageChangeOfAccumulationProp;
private SerializedProperty _generalPercentageChangeOfMultiplicationProp;
// References
private SerializedProperty _prefabRefsProp;
private SerializedProperty _derivativeCardDataRefsProp;
private SerializedProperty _derivativeCharacterDataRefsProp;
private SerializedProperty _belongingCardDataRefsProp;
protected override void OnEnable()
{
base.OnEnable();
// --- 在OnEnable中找到所有属性 ---
_haveCustomClassProp = serializedObject.FindProperty("haveCustomClass");
_modNameProp = serializedObject.FindProperty("modName");
_classNameProp = serializedObject.FindProperty("className");
_displayNameProp = serializedObject.FindProperty("displayName");
_tagsProp = serializedObject.FindProperty("tags");
_equipmentRarityProp = serializedObject.FindProperty("equipmentRarity");
_equipmentIconProp = serializedObject.FindProperty("equipmentIcon");
_equipmentDescriptionProp = serializedObject.FindProperty("equipmentDescription");
_coreNumericChangeProp = serializedObject.FindProperty("coreNumericChange");
_corePercentageChangeOfAccumulationProp = serializedObject.FindProperty("corePercentageChangeOfAccumulation");
_corePercentageChangeOfMultiplicationProp = serializedObject.FindProperty("corePercentageChangeOfMultiplication");
_generalNumericChangeProp = serializedObject.FindProperty("generalNumericChange");
_generalPercentageChangeOfAccumulationProp = serializedObject.FindProperty("generalPercentageChangeOfAccumulation");
_generalPercentageChangeOfMultiplicationProp = serializedObject.FindProperty("generalPercentageChangeOfMultiplication");
_prefabRefsProp = serializedObject.FindProperty("prefabRefs");
_derivativeCardDataRefsProp = serializedObject.FindProperty("derivativeCardDataRefs");
_derivativeCharacterDataRefsProp = serializedObject.FindProperty("derivativeCharacterDataRefs");
_belongingCardDataRefsProp = serializedObject.FindProperty("belongingCardDataRefs");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
// --- 按照你在EquipmentData.cs中声明的顺序手动绘制所有字段 ---
EditorGUILayout.LabelField("Fundamental", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(_haveCustomClassProp);
// --- 核心逻辑:根据 haveCustomClass 的值来决定显示/隐藏 ---
if (_haveCustomClassProp.boolValue)
{
// 如果勾选则显示class选择器 (假设基类为EquipmentBase, 命名空间为.Equipments)
if (DrawTypeSelectorGUI(_classNameProp, "Equipment Class", typeof(EquipmentBase), out Type outType, "Continentis.Mods", ".Equipments"))
{
string className = _classNameProp.stringValue;
string modName = outType.Namespace!.Replace("Continentis.Mods.", "").Split('.')[0];
string displayName = "Card_" + modName + "_" + className + "_DisplayName";
_modNameProp.stringValue = modName;
_displayNameProp.stringValue = displayName;
}
EditorGUI.BeginDisabledGroup(true);
}
EditorGUILayout.PropertyField(_modNameProp);
EditorGUILayout.PropertyField(_classNameProp);
EditorGUILayout.PropertyField(_displayNameProp);
if (_haveCustomClassProp.boolValue)
{
EditorGUI.EndDisabledGroup();
}
EditorGUILayout.PropertyField(_tagsProp, true);
EditorGUILayout.PropertyField(_equipmentRarityProp);
EditorGUILayout.PropertyField(_equipmentIconProp);
EditorGUILayout.PropertyField(_equipmentDescriptionProp);
EditorGUILayout.Space();
EditorGUILayout.LabelField("Attributes", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(_coreNumericChangeProp, true);
EditorGUILayout.PropertyField(_corePercentageChangeOfAccumulationProp, true);
EditorGUILayout.PropertyField(_corePercentageChangeOfMultiplicationProp, true);
EditorGUILayout.PropertyField(_generalNumericChangeProp, true);
EditorGUILayout.PropertyField(_generalPercentageChangeOfAccumulationProp, true);
EditorGUILayout.PropertyField(_generalPercentageChangeOfMultiplicationProp, true);
EditorGUILayout.Space();
EditorGUILayout.LabelField("References", EditorStyles.boldLabel);
DrawCharacterListGUI<GameObject>(_prefabRefsProp);
DrawCharacterListGUI<CardData>(_derivativeCardDataRefsProp);
DrawCharacterListGUI<CharacterData>(_derivativeCharacterDataRefsProp);
DrawCharacterListGUI<CardData>(_belongingCardDataRefsProp);
// 处理所有可能发生的ObjectPicker事件
HandleObjectPicker();
serializedObject.ApplyModifiedProperties();
}
}
}
#endif