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 Unity default theme

Discussion in 'UI Toolkit' started by Hellfim, May 30, 2023.

  1. Hellfim

    Hellfim

    Joined:
    Sep 11, 2014
    Posts:
    92
    I know it's possible to access default theme using @IMpoRt url("unity-theme://default"), but where is this default file stored?
     
  2. griendeau_unity

    griendeau_unity

    Unity Technologies

    Joined:
    Aug 25, 2020
    Posts:
    230
    Unfortunately, the default theme is an internal asset that we ship with Unity, so it is not possible to access it, unless you have Unity source code access, with Enterprise license I believe.
     
  3. Hellfim

    Hellfim

    Joined:
    Sep 11, 2014
    Posts:
    92
    Sorry, for double-checking but it's also unavailable at unity cs reference at github, yes (I didn't find it)?

    For those in need of the default theme - you can gather all of the expected values through UI Toolkit Debugger.
    I wanted override some values (like default button selectors, margins, paddings, texts, etc) and ended up with following .tss file which doesn't reference default theme:

    Code (Uxml):
    1.  
    2. :root {
    3.     font-size: 14px;
    4.     -unity-font-definition: resource('<YOUR_DEFAULT_FONT>');
    5.     color: rgba(255, 255, 255, 255);
    6. }
    7.  
    8. .unity-label {
    9.     flex: 0 0 auto;
    10.     margin: 0;
    11.     padding: 0;
    12.     white-space: nowrap;
    13. }
    14.  
    15. .unity-button {
    16.     border-radius: 0;
    17.     -unity-text-align: middle-center;
    18.     flex: 0 0 auto;
    19.     overflow: visible;
    20.     white-space: nowrap;
    21.     border-width: 0;
    22.     padding: 0;
    23.     margin: 0;
    24. }
    25.  
    26. .unity-scroll-view {
    27.     flex-shrink: 1;
    28. }
    29.  
    30. .unity-scroll-view__content-and-vertical-scroll-container {
    31.     flex-direction: row;
    32.     flex-grow: 1;
    33. }
    34.  
    35. .unity-scroll-view__content-viewport {
    36.     flex: auto;
    37.     overflow: hidden;
    38. }
    39.  
    40. .unity-scroll-view--horizontal > .unity-scroll-view__content-and-vertical-scroll-container > .unity-scroll-view__content-viewport {
    41.     flex-direction: row;
    42.     flex-grow: 1;
    43. }
    44.  
    45. .unity-scroll-view__content-container {
    46.     flex-shrink: 0;
    47. }
    48.  
    49. .unity-scroll-view--horizontal > .unity-scroll-view__content-and-vertical-scroll-container > .unity-scroll-view__content-viewport > .unity-scroll-view__content-container {
    50.     flex-direction: row;
    51.     flex-grow: 1;
    52. }
    53.  
    54. .unity-scroll-view--horizontal.unity-scroll-view--scroll > .unity-scroll-view__content-and-vertical-scroll-container > .unity-scroll-view__content-viewport > .unity-scroll-view__content-container {
    55.     overflow: scroll;
    56. }
    57.  
    58. .unity-ui-document__root {
    59.     position: absolute;
    60.     left: 0;
    61.     right: 0;
    62.     top: 0;
    63.     bottom: 0;
    64. }

    This file lacks selectors for vertical scroll view (and most likely some other selectors), but I don't need them so it should be fine.