I prefer use [ExecuteInEditMode] instead of overriding defaults because you can edit it realtime in editor and you can grouping all texts , then set defaults to different groups of them.I know you want pervent repetitious work(changing defaults) by overriding defaults but you can't grouping them.
for example:
group1(Menu fonts features) : font = 15;fontstyle = Normal,.....
group2(Score board fonts features) : font = 20;fontstyle = Bold ,.....
group3(Button fonts features) : font = 10;fontstyle = Italic,.....
but If you override them you have to change default again for some text,so you're limit in this way.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
[ExecuteInEditMode]
public class ChangeFontSize : MonoBehaviour {
public enum FontStyles{Normal,Bold,Italic,BoldAndItalic};
public FontStyles ActiveState = FontStyles.Normal;
public Color color;
public Text[] AllText;
public bool ChangeDefault;
[Range(0,15)]
public int size;
void Update(){
AllText = Object.FindObjectsOfType (typeof(Text)) as Text[];
if(ChangeDefault == true){
foreach (Text txt in AllText) {
txt.fontSize = size;
FStyle (txt);
}
}
}
//pass text components here
void FStyle(Text mytext){
switch(ActiveState)
{
// Check one case
case FontStyles.Normal:
//Set Normal Font style
mytext.fontStyle = FontStyle.Normal;
break;
case FontStyles.Bold:
//Set Bold Font style
mytext.fontStyle = FontStyle.Bold;
break;
case FontStyles.Italic:
//Set Italic Font style
mytext.fontStyle = FontStyle.Italic;
break;
case FontStyles.BoldAndItalic:
//Set BoldAndItalic Font style
mytext.fontStyle = FontStyle.BoldAndItalic;
break;
}
}
}