How can I change the default settings for the standard components or is this even possible? E.g. setting the default font-size for a text component so that each new text component I add will have the same font-size?

  • \$\begingroup\$ I have no idea if this is possible, but you know you could make prefabs right? \$\endgroup\$
    – DH.
    Oct 13, 2016 at 11:48
  • \$\begingroup\$ Sure, but I got for example one default font for my whole project, and it's a way better workflow to add a textcomponent which hat set this font as default instead of dragging a prefab into my scene. \$\endgroup\$
    – TobiasW
    Oct 13, 2016 at 11:55

2 Answers 2


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 easily. for example:

ExecuteInEditMode methode:

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,.....

override methode:

all text default fonts = 15;fontstyle = Normal,.....

but If you override them you have to change default again for some text,so you're limit in this way.this is mean you need many overriding classes foreach component.

this is basic using ExecuteInEditMode methode without grouping(for all text component in scene):

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

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;
    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){
        // Check one case
        case FontStyles.Normal: 
            //Set Normal Font style
            mytext.fontStyle = FontStyle.Normal;
        case FontStyles.Bold: 
            //Set Bold Font style
            mytext.fontStyle = FontStyle.Bold;
        case FontStyles.Italic: 
            //Set Italic Font style
            mytext.fontStyle = FontStyle.Italic;
        case FontStyles.BoldAndItalic: 
            //Set BoldAndItalic Font style
            mytext.fontStyle = FontStyle.BoldAndItalic;
  • \$\begingroup\$ Will I still be able to change the FontStyle manually after adding this script or will it lock the FontStyle option? \$\endgroup\$
    – TobiasW
    Oct 14, 2016 at 5:53

Perhaps you can achieve this by extending the component and overriding the right properties? Just spit balling here.



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .