How to pull string to equal text boxes in a more advanced custom editor tool.

I have a script that relies on another script to pull the highest value out of a vector2 that keeps track of the cells in my scene and the text boxes on that tool need to show the highest x and y in that editor tool only I cannot seem to get the tool to display anything in the text boxes other than 0 for both x and y despite how many cell I spawn on scene.

using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;

public class NewCellWindow : EditorWindow {

    //Declare Variables for the Cell Creation Window.
    public GameObject cell;

    int cellSize = GlobalCellInfo.cellSize;

    string cellName = "Wilderness";
    int xPosition = 0;
    int yPosition = 0;

    string xString = "0";
    string yString = "0";

    [MenuItem("Heightmap/Create Cell %#c")]
    static void Init()
    {
        //Used to open the cell creation window.
        NewCellWindow newCellWindow = (NewCellWindow)GetWindow(typeof(NewCellWindow));
        newCellWindow.maxSize = new Vector2(255f, 75f);
        newCellWindow.minSize = newCellWindow.maxSize;
        newCellWindow.Show();
    }

    void OnGUI()
    {
        GlobalCellInfo.InitialCellScan();
        GlobalCellInfo.Load(cell);

        GlobalCellInfo.highestX.ToString(xString);
        GlobalCellInfo.highestY.ToString(yString);

        if (cell != null) {
            //Set up the Cell Creation Window.
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Cell Name");
            cellName = GUILayout.TextField(cellName);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("X");
            xString = GUILayout.TextField(xString, 5);
            GUILayout.Label("Y");
            yString = GUILayout.TextField(yString, 5);
            EditorGUILayout.EndHorizontal();

            GUI.backgroundColor = Color.blue;
            if (GUILayout.Button("Create Cell", GUILayout.Width(250), GUILayout.Height(30)))
            {
                Vector2 cellPosition = new Vector2(int.Parse(xString), int.Parse(yString));
                if (GlobalCellInfo.existingCells.Contains(cellPosition))
                {
                    GlobalCellInfo.InitialCellScan();
                    GlobalCellInfo.highestX.ToString(xString);
                    GlobalCellInfo.highestY.ToString(yString);

                    ErrorCodeT.x0001(cellPosition);
                }
                else
                {
                    GlobalCellInfo.InitialCellScan();
                    GlobalCellInfo.highestX.ToString(xString);
                    GlobalCellInfo.highestY.ToString(yString);

                    CreateCell();
                }
            }
        }
        else
        {
            ErrorCodeT.x0000();
        }
    }

    void CreateCell()
    {
        xPosition = (int.Parse(xString) * cellSize);
        yPosition = (int.Parse(yString) * cellSize);

        GameObject newCell = Instantiate(cell);
        newCell.name = (cellName + " (" + (xPosition / cellSize) + ", " + (yPosition / cellSize) + ")");
        newCell.transform.localPosition = new Vector3(xPosition, 0, yPosition);
        newCell.transform.localRotation = Quaternion.Euler(-90, 0, 0);
        newCell.tag = "Cell";

        newCell.layer = 8;

        newCell.isStatic = true;

        newCell.AddComponent<CellInfo>();
        CellInfo.cellNameInfo = cellName;
        CellInfo.cellPositionInfo = new Vector2(xPosition, yPosition);

        newCell.AddComponent<LODGroup>();
        newCell.AddComponent<MeshCollider>();

        Vector2 newCellPosition = new Vector2((xPosition / cellSize), (yPosition / cellSize));

        GlobalCellInfo.InitialCellScan();
    }
}

the second script used mostly for variable storage and updating the Vector2

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

class GlobalCellInfo
{
    //Declare global variables that all terrain scripts can use.
    public static int cellSize = 64;

    public static List<Vector2> existingCells = new List<Vector2>();

    public static float highestX;
    public static float highestY;

    //Used for terrain scripts to load the global cell object.
    public static void Load(GameObject cell)
    {
        cell = Resources.Load("Mesh/Environment/Cells/Cell.blend/") as GameObject;
    }

    //Used to scan the scene for all existing cells.
    public static void InitialCellScan()
    {
        //Scan every object in the scene for tag "Cell" and clear the existing list.
        GameObject[] scannedCells = GameObject.FindGameObjectsWithTag("Cell");
        existingCells.Clear();

        if (scannedCells != null)
        {
            //Cycles through teh list of cells that was just scanned and add it to a static list.
            foreach (GameObject scannedCell in scannedCells)
            {
                Vector2 scannedCellPosition = new Vector2((scannedCell.transform.localPosition.x / cellSize), (scannedCell.transform.localPosition.z / cellSize));

                existingCells.Add(scannedCellPosition);
            }
        }

        //Check the value of each cell cell and use the lowest values.
        foreach (Vector2 cell in existingCells)
        {
            if (cell.x < highestX) highestX = cell.x + 1;
            if (cell.y < highestY) highestY = cell.y + 1;
        }
    }
}

Here is the fix.

you’re going to laugh

using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;

public class NewCellWindow : EditorWindow {

    //Declare Variables for the Cell Creation Window.
    public GameObject cell;

    int cellSize = GlobalCellInfo.cellSize;

    string cellName = "Wilderness";
    int xPosition = 0;
    int yPosition = 0;

    string xString = "0";
    string yString = "0";

    [MenuItem("Heightmap/Create Cell %#c")]
    static void Init()
    {
        //Used to open the cell creation window.
        NewCellWindow newCellWindow = (NewCellWindow)GetWindow(typeof(NewCellWindow));
        newCellWindow.maxSize = new Vector2(255f, 75f);
        newCellWindow.minSize = newCellWindow.maxSize;
        newCellWindow.Show();
    }

    void OnGUI()
    {
        GlobalCellInfo.InitialCellScan();
        GlobalCellInfo.Load(cell);

        //xString = GlobalCellInfo.highestX.ToString();
        //yString = GlobalCellInfo.highestY.ToString();

        if (cell != null) {
            //Set up the Cell Creation Window.
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Cell Name");
            cellName = GUILayout.TextField(cellName);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("X");
            xString = GUILayout.TextField(xString, 5);
            GUILayout.Label("Y");
            yString = GUILayout.TextField(yString, 5);
            EditorGUILayout.EndHorizontal();

            GUI.backgroundColor = Color.blue;
            if (GUILayout.Button("Create Cell", GUILayout.Width(250), GUILayout.Height(30)))
            {
                Vector2 cellPosition = new Vector2(int.Parse(xString), int.Parse(yString));
                if (GlobalCellInfo.existingCells.Contains(cellPosition))
                {
                    GlobalCellInfo.InitialCellScan();
                    xString = GlobalCellInfo.highestX.ToString();
                    yString = GlobalCellInfo.highestY.ToString();

                    ErrorCodeT.x0001(cellPosition);
                }
                else
                {
                    GlobalCellInfo.InitialCellScan();
                    //xString = GlobalCellInfo.highestX.ToString();
                    //yString = GlobalCellInfo.highestY.ToString();

                    CreateCell();
                    xString = GlobalCellInfo.highestX.ToString();  //this was the fix
                    yString = GlobalCellInfo.highestY.ToString();  //this was the fix
                }
            }
        }
        else
        {
            ErrorCodeT.x0000();
        }
    }

    void CreateCell()
    {
        xPosition = (int.Parse(xString) * cellSize);
        yPosition = (int.Parse(yString) * cellSize);

        GameObject newCell = Instantiate(cell);
        Vector2 newCellPosition = new Vector2((xPosition / cellSize), (yPosition / cellSize));
        newCell.name = (cellName + " (" + newCellPosition.x + ", " + newCellPosition.y + ")");
        newCell.transform.localPosition = new Vector3(xPosition, 0, yPosition);
        newCell.transform.localRotation = Quaternion.Euler(-90, 0, 0);
        newCell.tag = "Cell";

        newCell.layer = 8;

        newCell.isStatic = true;

        newCell.AddComponent<MeshCollider>();
        newCell.AddComponent<LODGroup>();

        newCell.AddComponent<CellInfo>();
        CellInfo.cellNameInfo = cellName;
        CellInfo.cellPositionInfo = new Vector2(xPosition, yPosition);

        GlobalCellInfo.InitialCellScan();
    }
}

All my Debugs to find the issue

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

class GlobalCellInfo
{
    //Declare global variables that all terrain scripts can use.
    public static string worldName = "Faelaria";

    public static int cellSize = 64;

    public static List<Vector2> existingCells = new List<Vector2>();

    public static float highestX;
    public static float highestY;

    //Used for terrain scripts to load the global cell object.
    public static void Load(GameObject cell)
    {
        cell = Resources.Load("Mesh/Environment/Cells/Cell.blend/") as GameObject;
    }

    //Used to scan the scene for all existing cells.
    public static void InitialCellScan()
    {
        Debug.Log("InitialCellScan Start");
        Debug.Log("highestX = " + highestX);
        Debug.Log("highestY = " + highestY);
        //Scan every object in the scene for tag "Cell" and clear the existing list.
        GameObject[] scannedCells = GameObject.FindGameObjectsWithTag("Cell");
        existingCells.Clear();

        if (scannedCells != null)
        {
            //Cycles through teh list of cells that was just scanned and add it to a static list.
            foreach (GameObject scannedCell in scannedCells)
            {
                Debug.Log(" divide : " + scannedCell.transform.localPosition.x / cellSize);
                Vector2 scannedCellPosition = new Vector2((scannedCell.transform.localPosition.x / cellSize), (scannedCell.transform.localPosition.z / cellSize));

                existingCells.Add(scannedCellPosition);
            }
        }

        //Check the value of each cell cell and use the highest values.
        foreach (Vector2 cell in existingCells)
        {
            Debug.Log("cell count = " + existingCells.Count);
            Debug.Log("existingCells ForEach loop x = " + cell.x + " : " + highestX);
            Debug.Log("existingCells ForEach loop y = " + cell.y + " : " + highestY);
            if (cell.x > highestX) highestX = cell.x + 1;
            if (cell.y > highestY) highestY = cell.y + 1;
        }
    }
}