Search Unity

[SOLVED] How to change the font for every text object?

Discussion in 'UGUI & TextMesh Pro' started by Deleted User, Feb 3, 2015.

  1. Deleted User

    Deleted User

    Guest

    Don't want to do it manually. I remember there being a way to change the font and apply for every item.
     
  2. LunaticEdit

    LunaticEdit

    Joined:
    May 1, 2014
    Posts:
    60
    In C# it's most likely going to be something like (i'm freehanding here..)

    Code (CSharp):
    1. var textComponents = Component.FindObjectsOfType<Text>();
    2. foreach(var component in textComponents)
    3.     component.font = <whatever>;
     
    WildSnakeAndy and HappyTurtles like this.
  3. BMayne

    BMayne

    Joined:
    Aug 4, 2014
    Posts:
    186
    if you are just trying to change all the fonts in a scene you could use search by type and put in "text". Then select all the objects and change the font.
     

    Attached Files:

  4. Deleted User

    Deleted User

    Guest

    I think there's a way to do without code. I want to do it in the editor. I remember something about creating a "UI object" where you can set everything about the current UI.
     
  5. BMayne

    BMayne

    Joined:
    Aug 4, 2014
    Posts:
    186
    You are most likely thinking of prefabs. I am going to make a guess and say all your text objects are not prefabs (they are blue). If they are not you will have to do this by hand using one of the two options.
     
  6. Deleted User

    Deleted User

    Guest

    Hmmm no not prefabs. I think they may have removed it in 4.6 but I'm 100% sure the old UI had a UI object and you could set how all the UI would behave in it.
     
  7. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    No, unless maybe you had some kind of third-party utility that did so. Nothing was removed in 4.6.

    --Eric
     
  8. BMayne

    BMayne

    Joined:
    Aug 4, 2014
    Posts:
    186
    Ya I am not sure what you are referring to. No functionality has been removed just for 4.6.0. Regardless the only way to update the current UI is the way we stated.
     
    Deleted User likes this.
  9. Deleted User

    Deleted User

    Guest

    Alright I must have been mistaken. Thanks guys. :)
     
  10. Feaver1968

    Feaver1968

    Joined:
    Nov 16, 2014
    Posts:
    70
    The old guiskin used to do that... Kind of
     
  11. Deleted User

    Deleted User

    Guest

    Oh I think that's what I meant.

    @BMayne 's suggestion ended up doing it for me. Thanks.
     
    Last edited by a moderator: Feb 10, 2015
  12. METAIRONY

    METAIRONY

    Joined:
    Nov 27, 2018
    Posts:
    1
    YOU SAVED MY LIFE
     
  13. alexandermsummers

    alexandermsummers

    Joined:
    Oct 27, 2020
    Posts:
    1
    If anyone's having trouble: you can select all the objects by clicking one followed by holding down CTRL+A. You can deselect the level by going to it, and holding down CTRL+left click. Then, go to the Text component in the Inspector and switch the font there.
     
  14. pginiotis

    pginiotis

    Unity Technologies

    Joined:
    Jul 10, 2018
    Posts:
    2
    If your text objects are not necessarily named text, you can do this by type, i.e. type in t:tmp_text in the hierarchy search, all the textmeshpro texts will appear in the list.
     
  15. EvilSaint007

    EvilSaint007

    Joined:
    Sep 21, 2021
    Posts:
    3
    Thank you so much. I was looking for the same for TextMeshPro
     
    ngfilms and P_Unterhose like this.
  16. BenMora

    BenMora

    Joined:
    Jul 6, 2021
    Posts:
    7
    I realize this is a very old thread, but here's what I just did which worked perfectly!

    As long as you are simply trying to replace ALL references to a font with a different font:
    1. Put the new font in the same location as the old one.
    2. Copy the name of the old font.
    3. Delete the old font.
    4. Rename the new font by pasting the old name.
    5. Open or refresh/reimport in Unity so the meta files get updated.
    6. In Unity rename the font to the new name.
    Now check all your text components and they will show the new font.