I am beginner in Unity and try to create my First Game.
Right now I try to write script that full my field by Hexs, that looks like this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HexManager : MonoBehaviour
{
[SerializeField] private float _width, _height;
[SerializeField] private float _Xstart, _Ystart, _Xstep, _Ystep, _shift;
[SerializeField] private Hex _tilePrefab;
[SerializeField] private Transform _cam;
void Start()
{
GenerateGrid();
}
void GenerateGrid()
{
for (float y = _Ystart, i = 0; y > _Ystart - _height * _Ystep; y -= _Ystep, i++)
{
float shift = 0;
if (i % 2 != 0) shift = _shift;
for (float x = shift + _Xstart, j = 0; y < shift + _Xstart + _width * _Xstep; y += _Xstep, j++)
{
var spawnedTile = Instantiate(_tilePrefab, new Vector3(x, y), Quaternion.identity);
spawnedTile.name = $"Hex {i} {j}";
}
}
}
}
!(Screenshot 2 — Postimages]
And every time, firstly my project closes, in few time. Then I try restart it and there is appeared message “it looks like another unity instance is running with this project open. Multiple Unity instances cant open the same project.”
After that I already can’t run my project, when I tap “Play” button, Editor just freeze and I can close it only with Task Manager. I’ve try to copy project, re-create it, but every time I bump into such error. And so about five times
Also I read on old forums that reason in Lockfile in Temp Folder, but I can’t to delete it. Of course I can every time backup my project, but it will be too tiresome, if create big project))



