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] public class NodeMap { [ReadOnly] public Vector3 node1; [ReadOnly] public Vector3 node2; [ShowInInspector] [HorizontalGroup("Bottom")] [BoxGroup("Bottom/Node1")] [HideLabel] private Transform node1Transform { get { return null; } set { if (value) node1 = value.position; } } [ShowInInspector] [BoxGroup("Bottom/Node2")] [HideLabel] private Transform node2Transform { get { return null; } set { if (value) node2 = value.position; } } } [SerializeField] public NodeMap[] nodeMaps; #if UNITY_EDITOR private HashSet _names; private HashSet _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(); var wayPointFlags = FindObjectsOfType(); 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 } }