Change the object’s color when clicked one and change back when clicked elsewhere

I’m sorry if this is a noob question but I just started with unity.
So there’s various tiles in the game and I managed to change the color of the tile that I clicked on and the adjacent tiles too, which is fine, but I want it to change back to the original color if I click on any other tile.
_
At the moment it toggles the color when I click so only if I click on the same tile will it change to the original color, which means that if I click on any other tile the ones I clicked on before will still be colored.
_
How could I go about changing the previous selected tiles back to original before I change the colors of the ones I just clicked on?
_
I’m using ray casts to find the tile that I clicked on.
Many thanks
_
This is the code for my script that manages the ray casts. The way I was trying to go about it was to save the previously clicked tile game objects in an array. Then before colouring new tiles i go through the tiles in the array and colour them back.
_
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;

public class MouseManager : MonoBehaviour
{

    Unit selectedUnit;
    GameObject[] coloredObjects = new GameObject[0];

    void Start()
    {
        
    }

    void Update()
    {

        if (EventSystem.current.IsPointerOverGameObject())
        {
            return;
        }


        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        RaycastHit hitInfo;

        if (Physics.Raycast(ray, out hitInfo))
        {
            GameObject ourHitObject = hitInfo.collider.transform.parent.gameObject;

            if (ourHitObject.GetComponent<Hex>() != null)
            {
                if (coloredObjects.Length != 0)
                {
                    MeshRenderer mr = ourHitObject.GetComponentInChildren<MeshRenderer>();
                    mr.material.color = Color.white;

                    for (int i = 0; i < ourHitObject.GetComponent<Hex>().GetNeighbours().Length; i++)
                    {
                        MeshRenderer mrNeighbour = ourHitObject.GetComponent<Hex>().GetNeighbours()*.GetComponentInChildren<MeshRenderer>();*

mrNeighbour.material.color = Color.white;
}

GameObject[] coloredObjects = new GameObject[(ourHitObject.GetComponent().GetNeighbours().Length) + 1];
for (int i = 0; i < ourHitObject.GetComponent().GetNeighbours().Length; i++)
{
coloredObjects = ourHitObject.GetComponent().GetNeighbours();
}
coloredObjects[(ourHitObject.GetComponent().GetNeighbours().Length) + 1] = ourHitObject;
MouseOver_Hex(ourHitObject);

}
else if (coloredObjects.Length == 0)
{
GameObject[] coloredObjects = new GameObject[(ourHitObject.GetComponent().GetNeighbours().Length) + 1];
for (int i = 0; i < ourHitObject.GetComponent().GetNeighbours().Length; i++)
{
coloredObjects = ourHitObject.GetComponent().GetNeighbours();
}
coloredObjects[ourHitObject.GetComponent().GetNeighbours().Length] = ourHitObject;
MouseOver_Hex(ourHitObject);
}
}
else if (ourHitObject.GetComponent() != null)
{

MouseOver_Unit(ourHitObject);

}

}

}

void MouseOver_Hex(GameObject ourHitObject)
{
Debug.Log("Raycast hit: " + ourHitObject.name);
GameObject[] neighbours;
neighbours = ourHitObject.GetComponent().GetNeighbours();

if (Input.GetMouseButtonDown(0))
{

MeshRenderer mr = ourHitObject.GetComponentInChildren();

if (mr.material.color == Color.red)
{
mr.material.color = Color.white;
}
else
{
mr.material.color = Color.red;
}

for (int i = 0; i < neighbours.Length; i++)
{
MeshRenderer mrNeighbour = neighbours*.GetComponentInChildren();*
if (mrNeighbour.material.color == Color.blue)
{
mrNeighbour.material.color = Color.white;
}
else
{
mrNeighbour.material.color = Color.blue;
}
}

if (selectedUnit != null)
{
selectedUnit.destination = ourHitObject.transform.position;
}

}

}

void MouseOver_Unit(GameObject ourHitObject)
{
Debug.Log("Raycast hit: " + ourHitObject.name);

if (Input.GetMouseButtonDown(0))
{

selectedUnit = ourHitObject.GetComponent();
}

}
}

save the previous tile in a gameobject and save the previous color, and when you click a new one assign the previous tile the previous color.