using UnityEngine;
|
|
#if UNITY_EDITOR
|
using UnityEditor;
|
#endif
|
|
public class RefreshNPCView : MapEventView
|
{
|
public int NpcID;
|
public bool randomPostion;
|
public float randomDist;
|
public int count = 1;
|
public float refreshInterval;
|
public int waveCount = 1;
|
public float waveInterval;
|
public E_ClientNpcType npcType;
|
|
}
|
|
#if UNITY_EDITOR
|
[CustomEditor(typeof(RefreshNPCView))]
|
public class RefreshNPCViewEditor : Editor
|
{
|
public override void OnInspectorGUI()
|
{
|
serializedObject.Update();
|
|
RefreshNPCView _target = target as RefreshNPCView;
|
|
_target.NpcID = EditorGUILayout.IntField("NPCID", _target.NpcID);
|
_target.npcType = (E_ClientNpcType)EditorGUILayout.EnumPopup("Npc类型", _target.npcType);
|
_target.name = string.Format("RefreshNPC: {0}", _target.NpcID);
|
|
if (GUILayout.Button("矫正为屏幕中心点的坐标"))
|
{
|
SceneView _sceneView = SceneView.lastActiveSceneView;
|
Camera _camera = _sceneView.camera;
|
Vector3 _screenPosition = _camera.ViewportToScreenPoint(new Vector3(0.5f, 0.5f));
|
Ray _ray = _camera.ScreenPointToRay(_screenPosition);
|
RaycastHit _raycastHit;
|
if (Physics.Raycast(_ray, out _raycastHit, 10000, LayerUtility.WalkbleMask))
|
{
|
_target.transform.position = _raycastHit.point;
|
}
|
}
|
|
_target.randomPostion = EditorGUILayout.Toggle("是否随机坐标", _target.randomPostion);
|
if (_target.randomPostion)
|
{
|
_target.randomDist = EditorGUILayout.FloatField("随机距离", _target.randomDist);
|
}
|
|
_target.count = EditorGUILayout.IntField("单次数量", _target.count);
|
_target.refreshInterval = EditorGUILayout.FloatField("单次间隔", _target.refreshInterval);
|
|
_target.waveCount = EditorGUILayout.IntField("刷几波", _target.waveCount);
|
_target.waveInterval = EditorGUILayout.FloatField("每波间隔", _target.waveInterval);
|
|
if (GUI.changed)
|
{
|
EditorUtility.SetDirty(target);
|
serializedObject.ApplyModifiedProperties();
|
}
|
}
|
}
|
#endif
|