Files
ID/Assets/Code/Lab6/Vertex.cs
T
2026-02-18 10:43:12 +03:00

37 lines
899 B
C#

using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace Code.Lab6
{
[System.Serializable]
public class Vertex : MonoBehaviour
{
public int id = -1;
public List<Edge> neighbours;
[HideInInspector]
public Vertex prev;
private void Awake()
{
neighbours ??= new List<Edge>();
}
private void OnDrawGizmos()
{
Gizmos.color = Color.cyan;
Gizmos.DrawSphere(transform.position, 0.2f);
}
private void OnDrawGizmosSelected()
{
if (neighbours == null) return;
Gizmos.color = Color.yellow;
foreach (var edge in neighbours.Where(edge => edge?.Vertex != null))
{
Gizmos.DrawLine(transform.position, edge.Vertex.transform.position);
}
}
}
}