Resize font of all texts to the same value

I have some Text objects in UI. And I set Best Fit to true for all of them.the problem that I face,is that the length of their texts are variable,therefore their responsive font sizes are different from each other.
I tried to write this script to change the font size of all texts to the smallest one but it wont work. How can I overcome this problem?

public class FontResizer : MonoBehaviour {

    public Text[] txtBoxes;
    public float[] fontSizes;
    float min;

	void Start () {
        fontSizes = new float[txtBoxes.Length];

        for (int i = 0; i < fontSizes.Length; i++)
        {
            fontSizes _= txtBoxes*.cachedTextGenerator.fontSizeUsedForBestFit;*_

}

min = 100000;
for (int i = 0; i < fontSizes.Length; i++)
{
if (min > fontSizes*)*
{
min = fontSizes*;*
}
}

for (int i = 0; i < fontSizes.Length; i++)
{
txtBoxes*.resizeTextForBestFit = false;*
}

for (int i = 0; i < fontSizes.Length; i++)
{
txtBoxes*.fontSize = Mathf.FloorToInt(min);*
}

}
}

You need to delay a single frame size the “best fit” size is still being determined in Frame 1. Therefore, putting the code in a coroutine will help. I also cleaned it up a little

    public Text[] txtBoxes;

	void Start () 
	{
		StartCoroutine (SetTextSize ());	
	}
		
	IEnumerator SetTextSize ()
	{
		//Need to delay a frame
		yield return null;

		int minSize = 1000;

		//Find smallest
		for (int i = 0; i < txtBoxes.Length; i++)
		{
			if (minSize > txtBoxes *.cachedTextGenerator.fontSizeUsedForBestFit)*

_ minSize = txtBoxes .cachedTextGenerator.fontSizeUsedForBestFit;_
* }*

* //Set smallest*
* for (int i = 0; i < txtBoxes.Length; i++)*
* {*
_ txtBoxes*.resizeTextMaxSize = minSize;
}
}*_