for(int i=0;i<GlobalData.Objects.count;i++)
{
Сюда твое условие, но вместо нуля i
}
var selectedList = GlobalData.Objects.Where(x=>x.transform.position == pos).ToList();
[SerializeField] private Queue<GameObject> points;
public Vector2 GetTargetPosition()
{
if (points.Count == 0)
{
//destroy;
}
var point = points.Dequeue();
return point.transform.position;
}
public class Laser : MonoBehaviour
{
[SerializeField] private LineRenderer lineRenderer;
private void Update()
{
//Ray ray = new Ray(origin,direction);
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
lineRenderer.enabled = true;
var firstPosition = Camera.main.transform.position;
var secondPosition = hit.point;
lineRenderer.SetPosition(0, firstPosition);
lineRenderer.SetPosition(1, secondPosition);
}
else
{
lineRenderer.enabled = false;
}
}
}