7/27/2015 9:28:43 PM

The following code will get the Textcomponent of a GameObject and get the font size.

public static int Get_FontSize(Component component) { if (component != null) { Get_FontSize(component.gameObject); } return 0; } public static int Get_FontSize(GameObject gameObject) { if (gameObject != null) { var textObject = gameObject.GetComponent<UnityEngine.UI.Text>(); if (textObject == null) { textObject = gameObject.GetComponentInChildren<UnityEngine.UI.Text>(); } if (textObject != null) { return textObject.fontSize; } } return 0; }