Skip to main content
added 164 characters in body
Source Link

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):

but If you override them you have to change default again for some text,so you're limit in this way.

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):

added 119 characters in body
Source Link

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:

group3(Button fonts features) : font = 10;fontstyle = Italic,.....

override methode:

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

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:

group3(Button fonts features) : font = 10;fontstyle = Italic,.....

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:

group3(Button fonts features) : font = 10;fontstyle = Italic,.....

override methode:

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

Source Link

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; } } }