2024-04-04 23:51:14 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.SceneManagement;
|
|
|
|
|
|
|
|
|
|
namespace Game;
|
|
|
|
|
|
|
|
|
|
[ExecuteAlways]
|
|
|
|
|
public class GameGlobalConfig : SerializedMonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
[HideReferenceObjectPicker]
|
2024-04-05 18:12:04 +08:00
|
|
|
|
[System.Serializable]
|
2024-04-04 23:51:14 +08:00
|
|
|
|
public class NodeMap
|
|
|
|
|
{
|
|
|
|
|
[ReadOnly] public Vector3 node1;
|
|
|
|
|
[ReadOnly] public Vector3 node2;
|
|
|
|
|
|
2024-04-05 18:12:04 +08:00
|
|
|
|
[ReadOnly] public string node1Name;
|
|
|
|
|
[ReadOnly] public string node2Name;
|
|
|
|
|
|
2024-04-04 23:51:14 +08:00
|
|
|
|
[ShowInInspector]
|
|
|
|
|
[HorizontalGroup("Bottom")]
|
|
|
|
|
[BoxGroup("Bottom/Node1")]
|
|
|
|
|
[HideLabel]
|
|
|
|
|
private Transform node1Transform
|
|
|
|
|
{
|
|
|
|
|
get { return null; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value)
|
2024-04-05 18:12:04 +08:00
|
|
|
|
{
|
2024-04-04 23:51:14 +08:00
|
|
|
|
node1 = value.position;
|
2024-04-05 18:12:04 +08:00
|
|
|
|
node1Name = value.name;
|
|
|
|
|
}
|
2024-04-04 23:51:14 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ShowInInspector]
|
|
|
|
|
[BoxGroup("Bottom/Node2")]
|
|
|
|
|
[HideLabel]
|
|
|
|
|
private Transform node2Transform
|
|
|
|
|
{
|
|
|
|
|
get { return null; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value)
|
2024-04-05 18:12:04 +08:00
|
|
|
|
{
|
2024-04-04 23:51:14 +08:00
|
|
|
|
node2 = value.position;
|
2024-04-05 18:12:04 +08:00
|
|
|
|
node2Name = value.name;
|
|
|
|
|
}
|
2024-04-04 23:51:14 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[SerializeField] public NodeMap[] nodeMaps;
|
|
|
|
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
private HashSet<string> _names;
|
|
|
|
|
private HashSet<Transform> _points;
|
|
|
|
|
private GUIStyle _style;
|
|
|
|
|
[SerializeField] private bool _showGizmos = true;
|
|
|
|
|
[SerializeField] private bool _showPointLabel = true;
|
|
|
|
|
#endif
|
|
|
|
|
private void OnDrawGizmos()
|
|
|
|
|
{
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
if (_points == null || _points.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
var skinLabel = GUI.skin.label;
|
|
|
|
|
_style = new GUIStyle(skinLabel);
|
|
|
|
|
_style.normal.textColor = Color.red;
|
|
|
|
|
_style.fontStyle = FontStyle.Bold;
|
|
|
|
|
_points ??= new HashSet<Transform>();
|
|
|
|
|
var wayPointFlags = FindObjectsOfType<WayPointFlag>();
|
|
|
|
|
foreach (var wayPointFlag in wayPointFlags)
|
|
|
|
|
{
|
|
|
|
|
_points.Add(wayPointFlag.transform);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_showPointLabel)
|
|
|
|
|
{
|
|
|
|
|
foreach (var point in this._points)
|
|
|
|
|
{
|
|
|
|
|
if (point)
|
|
|
|
|
UnityEditor.Handles.Label(point.position, point.gameObject.name, _style);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!_showGizmos)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// var color = UnityEditor.Handles.color;
|
|
|
|
|
// UnityEditor.Handles.color = Color.red;
|
|
|
|
|
// UnityEditor.Handles.color = color;
|
|
|
|
|
|
|
|
|
|
if (nodeMaps != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var nodeMap in this.nodeMaps)
|
|
|
|
|
{
|
|
|
|
|
UnityEditor.Handles.DrawLine(nodeMap.node1, nodeMap.node2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|