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. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    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:
    3
    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:
    419
    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:
    3
    Unfortunately, that appears to be read only still (at least in 2021.3.16F1)
    Code (CSharp):
    1. public static TMP_StyleSheet defaultStyleSheet { get; }