'HashSet' does not contain a definition for 'ElementAt' в unity2d
юинити выдаёт следующую ошибку: Assets\scripts\SimpleRandomWalkDungeonGenerator.cs(35,46): error CS1061: 'HashSet<Vector2Int>' does not contain a definition for 'ElementAt' and no accessible extension method 'ElementAt' accepting a first argument of type 'HashSet<Vector2Int>' could be found (are you missing a using directive or an assembly reference?)
елси брать конкретную строчку к которой применима ошибка строчка 35 там код выглядит следующим образом: currentPosition = floorPositions.ElementAt(Random.Range(0, floorPositions.Count));
весь код выглядит следующим образом:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Random = UnityEngine.Random;
using UnityEngine.Tilemaps;
public class SimpleRandomWalkDungeonGenerator : MonoBehaviour
{
[SerializeField]
protected Vector2Int startPosition = Vector2Int.zero;
public int iterations = 10;
public int walkLength = 10;
public bool startRandomlyEachIteration = true;
[SerializeField]
private TilemapVisualizer tilemapVisualizer;
public void RunProceduralGeneration()
{
HashSet<Vector2Int> floorPositions = RunRandomWalk();
tilemapVisualizer.PaintFloorTiles(floorPositions);
}
protected HashSet<Vector2Int> RunRandomWalk()
{
var currentPosition = startPosition;
HashSet<Vector2Int> floorPositions = new HashSet<Vector2Int>();
for (int i = 0; i < iterations; i++)
{
var path = ProceduralGenerationAlgorithms.SimpleRandomWalk(currentPosition, walkLength);
floorPositions.UnionWith(path);
if (startRandomlyEachIteration)
currentPosition = floorPositions.ElementAt(Random.Range(0, floorPositions.Count));
}
return floorPositions;
}
}