Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Any way to swap TMP style sheet at runtime?

Discussion in 'UGUI & TextMesh Pro' started by travis-TAP-3D, Jan 12, 2023.

  1. travis-TAP-3D

    travis-TAP-3D

    Joined:
    Sep 12, 2022
    Posts:
    17
    Essentially I'm trying to have one style sheet for my VR platform (larger font sizes e.g.) vs another for my web/desktop product for the same project. I don't see any obvious API's to change the style sheet at runtime. Does anyone know a way? Thx!
     
  2. karliss_coldwild

    karliss_coldwild

    Joined:
    Oct 1, 2020
    Posts:
    530
    Have you looked at `TMP_Settings.defaultStyleSheet` ? In earlier versions of TMP it was read only, but now you can set it as well. I think I tried it once in the editor, but didn't test if it works in standalone build as well.
     
  3. travis-TAP-3D

    travis-TAP-3D

    Joined:
    Sep 12, 2022
    Posts:
    17
    Unfortunately, that appears to be read only still (at least in 2021.3.16F1)
    Code (CSharp):
    1. public static TMP_StyleSheet defaultStyleSheet { get; }