using UnityEngine; using System.Collections.Generic; #if UNITY_EDITOR using UnityEditor; #endif public class MissionTriggerView : MonoBehaviour { /// /// 任务id /// public int id; /// /// 任务状态 /// public int state; /// /// 任务触发事件列表 /// public List eventList = new List(); } #if UNITY_EDITOR [CustomEditor(typeof(MissionTriggerView))] public class MissionTriggerViewEditor : Editor { public override void OnInspectorGUI() { serializedObject.Update(); MissionTriggerView _target = target as MissionTriggerView; Transform _root = _target.transform; _target.id = EditorGUILayout.IntField("任务ID", _target.id); _target.state = EditorGUILayout.IntField("任务状态", _target.state); _target.name = string.Format("Mission_{0}", _target.id); if (GUILayout.Button("新建刷怪数据")) { RefreshNPCView _refreshNPCView = SoMapView.GeneralRefreshNpcView(_root); _target.eventList.Add(_refreshNPCView); Selection.activeGameObject = _refreshNPCView.gameObject; } if (GUILayout.Button("新建障碍点数据")) { CreateImpasseView _createImpasseView = SoMapView.GeneralCreateImpasseView(_root); _target.eventList.Add(_createImpasseView); Selection.activeGameObject = _createImpasseView.gameObject; } if (GUI.changed) { EditorUtility.SetDirty(target); serializedObject.ApplyModifiedProperties(); } } } #endif