Using UIToolkit With Settings Manager

Hey all,

I need some help with UI Toolkit and Settings Manager (Settings Manager | Settings Manager | 1.0.1).

TL;DR: How can I connect a UserSetting variable to a UI element so changes made in the Project Settings window are saved?

I’m building an editor tool and I want its settings to appear in the “Project Settings” window, similar to TextMesh Pro.

At first, I thought using a ScriptableObject to store the settings, but while researching I discovered Settings Manager. During that research, I learned that Unity is trying to dissuade people from using ScriptableObjects to store project settings (I can’t find that page anymore, I have too many tabs open and I might have closed it in a fit of frustration). So I figured, since this is a new project and the Settings Manager package is not in preview, I might as well use that.

I followed the (lacking) documentation and examples, and I encountered two approaches.

Approach A: use the UserSetting attribute to have it populate automatically and UserSettingsBlock attribute and use the “old” way of building editor controls (EditorGUI, EditorGUILayout, etc…).

Approach B: Create a ScriptableObject asset to store the settings and Build the UI using UIToolkit (Unity - Scripting API: SettingsProvider).

I tried approach A at first, and it worked and saved all the settings, but I struggled designing the UI. It is so cumbersome and uncomfortable to work with and get the result I need.

I switched to approach B, without the ScriptableObject, and managed to design the UI I needed, but can’t figure out how to connect the UI elements and the UserSetting variables I defined, so the problem is any change is not saved.

Can anyone point me in the right direction on how to connect a UserSetting variable to the UI element?

Well, I figured something out. In the method I added to “activateHandler”, I query for all the UI elements and register a method to each of them using “RegisterValueChangedCallback” to set the UserSetting I declared.