少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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