Node script is shared below. The Node script works fine when I run the game for the first time. However, while the game is running, when there is a change in the map, the list specified in the script needs to be updated (it should add the necessary elements to the list because the directions of the node whose list is empty are available) but it does not add.

Node gameobject is created and Node script is assigned to this object. Later, it was assigned to "Rule Tile" with the add-on of the additional package called "Tilemap Extras". Then, these points were drawn on the tilemap named "Nodes" with the tile palette.

I have made explanations on the sample pictures so that my question does not become complicated and there are no missing parts.

First image:

[![Unity Editor Screenshot][1]][1]

Second image:

[![Unity Editor Screenshot][2]][2]


    using UnityEngine;
    using System.Collections.Generic;

    public class Node : MonoBehaviour
    {
    public List<Vector2> availableDirections = new List<Vector2>();

    public LayerMask obstacleLayer;

    private void Start()
    {
        CalculateDirections();
    }

    public void CalculateDirections()
    {
        
        CheckAvailableDirections(Vector2.up);
        CheckAvailableDirections(Vector2.down);
        CheckAvailableDirections(Vector2.left);
        CheckAvailableDirections(Vector2.right);

        Debug.Log("CalculateDirections() FUNC WORKED");
    }

    private void CheckAvailableDirections(Vector2 direction)
    {
        RaycastHit2D hit = Physics2D.BoxCast(this.transform.position, Vector2.one * 1.5f, 0.0f, direction, 6.0f, this.obstacleLayer);

        Debug.Log("BOXCAST HIT WORKED");

        if (hit.collider == null)
        {
            this.availableDirections.Add(direction);

            Debug.Log("ADDED LIST");
        }
    }

    public void CalculateAgain()
    {
        CalculateDirections();
    }
    }


  [1]: https://i.sstatic.net/kF0uL.png
  [2]: https://i.sstatic.net/3ZdsF.png