using UnityEngine; using UnityEditor; [CustomEditor(typeof(SoConfigBase))] public class SoConfigBaseEditor : Editor { private GUIContent m_LabelCurve; private SerializedProperty m_Curve; private void OnEnable() { m_Curve = serializedObject.FindProperty("curve"); m_LabelCurve = new GUIContent("速度曲线"); } public override void OnInspectorGUI() { serializedObject.Update(); OnDrawInspectorGUI(); if (GUI.changed) { EditorUtility.SetDirty(target); serializedObject.ApplyModifiedProperties(); } } protected virtual void OnDrawInspectorGUI() { SoConfigBase _target = target as SoConfigBase; _target.floodPercent = EditorGUILayout.IntField("血量(万分率)", _target.floodPercent); GUILayout.Space(5); EditorGUILayout.LabelField("[技能位移]"); EditorGUILayout.HelpBox("1. 坐标系定义: 横轴为时间,纵轴为速度.\r\n2. 配置的时间尽量把握不要有2次位移的重叠,以免相互干扰,也不要超过总的动画时间.", MessageType.Info); _target.curve = AnimationCurveGUI.CurveField("速度曲线", _target.curve); if (_target.curve == null || _target.curve.keys.Length == 0) { _target.moveDuration = 0; } else { int _length = _target.curve.keys.Length; Keyframe _keyFrame = _target.curve.keys[_length - 1]; _target.moveDuration = _keyFrame.time; } EditorGUILayout.LabelField("位移时间", _target.moveDuration.ToString()); _target.moveThrougthEnable = EditorGUILayout.Toggle("位移是否穿透目标", _target.moveThrougthEnable); _target.forceMoveThrougthEnable = EditorGUILayout.Toggle("位移是否强制穿透目标(重量为0)", _target.forceMoveThrougthEnable); EditorGUILayout.LabelField("[镜头控制]"); _target.cameraSfxId = EditorGUILayout.IntField("摄像机控制配置", _target.cameraSfxId); EditorGUILayout.LabelField("[技能效果]"); _target.bodyControlId = EditorGUILayout.IntField("控制配置Id", _target.bodyControlId); _target.hitType = (E_HitType)EditorGUILayout.EnumPopup("目标被击类型", _target.hitType); _target.deadFlyId = EditorGUILayout.IntField("死亡击飞配置Id", _target.deadFlyId); _target.hitEffectId = EditorGUILayout.IntField("击中特效", _target.hitEffectId); _target.hitPauseTime = EditorGUILayout.IntField("使对方停顿(毫秒)", _target.hitPauseTime); } }