I made a custom inspector in unity to fill item collections.
but there is a problem, every time I change a line of code, unity updates and resets all previously filled fields and objects
for example, there is such a window. it sets borders that are impassable along the edge of the terrain
this window changes the data in the script
[System.Serializable]
[DisallowMultipleComponent]
public class GameArea : MonoBehaviour
{
private static GameArea _instance;
public static GameArea Instance()
{
if (_instance == null)
{
_instance = GameObject.FindObjectOfType<SuperTerrain>();
if (_instance == null)
{
_instance = new GameObject("Terrain", typeof(SuperTerrain)).GetComponent<SuperTerrain>();
}
}
return _instance;
}
private void Awake()
{
DontDestroyOnLoad(gameObject);
}
[SerializeField] public Vector2 MinCorner { get; private set; }
[SerializeField] public Vector2 MaxCorner { get; private set; }
public void SetCorner(float xMin, float xMax, float yMin, float yMax)
{
DeleteOldCorner();
MinCorner = new Vector2(xMin, yMin);
MaxCorner = new Vector2(xMax, yMax);
CreateCorner();
}
and every time i’m deleted the old borders with hands (because the links to them are lost) and open the first window to enter the data again.