Search Unity

Title style for Preferences window

Discussion in 'UI Toolkit' started by XGT08, Jun 6, 2020.

  1. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,906
    Hello,

    I am using the SettingsProvider API to provide editor preferences for a plugin I am working on. Everything seems to be working nicely, except for the fact that I would like to add a title in the same way as Unity does for each pref item. For example,

    PrefsWindow.png

    Clicking on the general item, brings up a UI and the title is General. I would like my settings page to follow the same pattern, but I don't know how to access the title property sheet/style.

    Thanks,
    Andrew
     
  2. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,906
    I don't think it's what I am looking for. It seems OnTitlebarGUI allows you to add stuff in addition to the title, however, in my case, it is the title that I would like to draw. I have already done it using UIElements, the title looks good, but I just wanted to make sure I am using the same style (e.g. font size, etc). In any case, it seems that it looks pretty close.
     
  3. It is the label.
    Code (CSharp):
    1. namespace UnityEngine.InputSystem.Editor
    2. {
    3.     internal class InputSettingsProvider : SettingsProvider, IDisposable
    4.     {
    5.         public const string kEditorBuildSettingsConfigKey = "com.unity.input.settings";
    6.         public const string kSettingsPath = "Project/Input System Package";
    7.  
    8.         public static void Open()
    9.         {
    10.             SettingsService.OpenProjectSettings(kSettingsPath);
    11.         }
    12.  
    13.         [SettingsProvider]
    14.         public static SettingsProvider CreateInputSettingsProvider()
    15.         {
    16.             return new InputSettingsProvider(kSettingsPath, SettingsScope.Project);
    17.         }
    18.  
    19.         private InputSettingsProvider(string path, SettingsScope scopes)
    20.             : base(path, scopes)
    21.         {
    22.             label = "Input System Package - LurkingNinja was h3r3";
    23.             s_Instance = this;
    24.         }
    25.  
    In this code on the 22nd line. I don't know too much about the SettingsProvider, but the Input System package sets its title/menu point this way. It worth mentioning that the left hand side label and the title label are the same in this case.

    answer.PNG
     
    XGT08 likes this.
  4. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,906
    I've tried the setting the label before, but it doesn't seem to have any effect. I am creating the GUI for the Preferences window. But I've tried with the project settings window and it doesn't work there either.

    EDIT: Hmm... Setting the label seems to only affect the name of the item in the tree view, but it doesn't show the title. Also, I tried implementing the OnTitleBarGUI hook and it seems it is not being called. For some reason, the title is not drawn.

    Thanks for the help though :)
     
    Last edited: Jun 7, 2020
  5. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,906
    It seems that I need to create the title myself as it is done in Unity's doc example:
    Title.png