| New file |
| | |
| | | using UnityEngine; |
| | | using System.Collections.Generic; |
| | | |
| | | #if UNITY_EDITOR |
| | | using UnityEditor; |
| | | #endif |
| | | |
| | | [CreateAssetMenu(menuName = "流程进度配置")] |
| | | public class SoProcessNode : ScriptableObject |
| | | { |
| | | public List<Node> nodeList = new List<Node>(); |
| | | |
| | | [System.Serializable] |
| | | public class Node |
| | | { |
| | | public ProcessNode.E_ProcessType nodeType; |
| | | public int param; |
| | | } |
| | | } |
| | | |
| | | #if UNITY_EDITOR |
| | | [CustomEditor(typeof(SoProcessNode))] |
| | | public class SoProcessNodeEditor : Editor |
| | | { |
| | | private GUISkin guiSkin; |
| | | public override void OnInspectorGUI() |
| | | { |
| | | if (guiSkin == null) |
| | | { |
| | | guiSkin = AssetDatabase.LoadAssetAtPath<GUISkin>("Assets/Scripts/Core/MapEditor/Editor/EditorResources/EditorSkin.guiskin"); |
| | | } |
| | | |
| | | serializedObject.Update(); |
| | | |
| | | var _root = target as SoProcessNode; |
| | | |
| | | int _removeIndex = -1; |
| | | |
| | | SoProcessNode.Node _node = null; |
| | | for (int i = 0; i < _root.nodeList.Count; ++i) |
| | | { |
| | | _node = _root.nodeList[i]; |
| | | |
| | | EditorGUILayout.BeginHorizontal(guiSkin.box); |
| | | |
| | | EditorGUILayout.LabelField((i + 1).ToString(), guiSkin.customStyles[2], GUILayout.Width(20), GUILayout.Height(22)); |
| | | |
| | | EditorGUILayout.BeginVertical(guiSkin.box); |
| | | |
| | | EditorGUILayout.BeginHorizontal(); |
| | | EditorGUILayout.LabelField("节点类型", GUILayout.Width(90)); |
| | | _node.nodeType = (ProcessNode.E_ProcessType)EditorGUILayout.EnumPopup(_node.nodeType); |
| | | EditorGUILayout.EndHorizontal(); |
| | | |
| | | if (_node.nodeType == ProcessNode.E_ProcessType.AttackCount) |
| | | { |
| | | _Item(ref _node, "攻击次数"); |
| | | } |
| | | else if (_node.nodeType == ProcessNode.E_ProcessType.BeAttackCount) |
| | | { |
| | | _Item(ref _node, "被击次数"); |
| | | } |
| | | else if (_node.nodeType == ProcessNode.E_ProcessType.HpPer) |
| | | { |
| | | _Item(ref _node, "生命值(百分率)"); |
| | | } |
| | | else if (_node.nodeType == ProcessNode.E_ProcessType.CommonAttack) |
| | | { |
| | | } |
| | | else if (_node.nodeType == ProcessNode.E_ProcessType.CastSkill) |
| | | { |
| | | _Item(ref _node, "使用技能"); |
| | | } |
| | | else if (_node.nodeType == ProcessNode.E_ProcessType.AutoAI) |
| | | { |
| | | } |
| | | else if (_node.nodeType == ProcessNode.E_ProcessType.WaitTime) |
| | | { |
| | | _Item(ref _node, "等待时间(毫秒)"); |
| | | } |
| | | else if (_node.nodeType == ProcessNode.E_ProcessType.LockHp) |
| | | { |
| | | _Item(ref _node, "锁定血量(百分率)"); |
| | | } |
| | | else if (_node.nodeType == ProcessNode.E_ProcessType.Die) |
| | | { |
| | | } |
| | | else if (_node.nodeType == ProcessNode.E_ProcessType.OpenDialog) |
| | | { |
| | | _Item(ref _node, "打开对话"); |
| | | } |
| | | else if (_node.nodeType == ProcessNode.E_ProcessType.ShowMotion) |
| | | { |
| | | _Item(ref _node, "表演动画"); |
| | | } |
| | | EditorGUILayout.EndVertical(); |
| | | if (GUILayout.Button("删除", GUILayout.Height(22))) |
| | | { |
| | | _removeIndex = i; |
| | | } |
| | | EditorGUILayout.EndHorizontal(); |
| | | } |
| | | |
| | | if (_removeIndex != -1) |
| | | { |
| | | _root.nodeList.RemoveAt(_removeIndex); |
| | | } |
| | | |
| | | if (GUILayout.Button("增加流程节点", guiSkin.button, GUILayout.Height(32))) |
| | | { |
| | | _root.nodeList.Add(new SoProcessNode.Node()); |
| | | } |
| | | |
| | | if (GUI.changed) |
| | | { |
| | | EditorUtility.SetDirty(target); |
| | | serializedObject.ApplyModifiedProperties(); |
| | | } |
| | | } |
| | | |
| | | private void _Item(ref SoProcessNode.Node node, string name) |
| | | { |
| | | EditorGUILayout.BeginHorizontal(); |
| | | EditorGUILayout.LabelField(name, GUILayout.Width(90)); |
| | | node.param = EditorGUILayout.IntField(node.param); |
| | | EditorGUILayout.EndHorizontal(); |
| | | } |
| | | } |
| | | #endif |