![]() ![]() This assumes you haven't added any children to the rootElement passed to the OnActivate function. Use this function to draw the UI based on IMGUI. Use this function to override drawing the footer for the SettingsProvider using IMGUI. Use this function to implement a handler for when the user clicks on another setting or when the Settings window closes. You can fetch a settings Asset or set up UIElements UI from this function. Use this function to implement a handler for when the user clicks on the Settings in the Settings window. SettingsProvider tries to match the search terms (even partially) to any of the SettingsProvider.keywords. Overrides SettingsProvider.OnTitleBarGUI.Ĭhecks whether the SettingsProvider should appear when the user types something in the Settings window search box. The path should be unique among all other settings paths and should use "/" as its separator. Gets Path used to place the SettingsProvider in the tree view of the Settings window. The Scope determines whether the SettingsProvider appears in the Preferences window (SettingsScope.User) or the Settings window (SettingsScope.Project). If not set, the Settings window uses last token of ttingsPath instead. Gets or sets the display name of the SettingsProvider as it appears in the Settings window. When the user enters values in the search box on the Settings window, SettingsProvider.HasSearchInterest tries to match those keywords to this list. Gets or sets the list of keywords to compare against what the user is searching for. Overrides SettingsProvider.OnInspectorUpdate. Overrides SettingsProvider.HasSearchInterest. Overrides SettingsProvider.OnFooterBarGUI. Settings Asset doesn't exist yet no need to display anything in the Settings window. Provider.keywords = GetSearchKeywordsFromGUIContentProperties() Automatically extract all keywords from the Styles. ![]() Var provider = new M圜ustomSettingsProvider("Project/M圜ustomSettingsProvider", SettingsScope.Project) M_CustomSettings.ApplyModifiedPropertiesWithoutUndo() Public override void OnGUI(string searchContext)ĮditorGUILayout.PropertyField(m_CustomSettings.FindProperty("m_Number"), Styles.number) ĮditorGUILayout.PropertyField(m_CustomSettings.FindProperty("m_SomeString"), Styles.someString) M_CustomSettings = M圜ustomSettings.GetSerializedSettings() This function is called when the user clicks on the M圜ustom element in the Settings window. Public override void OnActivate(string searchContext, VisualElement rootElement) Return File.Exists(k_M圜ustomSettingsPath) Public M圜ustomSettingsProvider(string path, SettingsScope scope = SettingsScope.User) Public static GUIContent someString = new GUIContent("Some string") Ĭonst string k_M圜ustomSettingsPath = "Assets/ Editor/M圜ustomSettings.asset" Public static GUIContent number = new GUIContent("My Number") Private SerializedObject m_CustomSettings Create M圜ustomSettingsProvider by deriving from SettingsProvider:Ĭlass M圜ustomSettingsProvider : SettingsProvider Populate the search keywords to enable smart search filtering and label highlighting: Settings.ApplyModifiedPropertiesWithoutUndo() Var settings = M圜ustomSettings.GetSerializedSettings() ĮditorGUILayout.PropertyField(settings.FindProperty("m_Number"), new GUIContent("My Number")) ĮditorGUILayout.PropertyField(settings.FindProperty("m_SomeString"), new GUIContent("My String")) Create the SettingsProvider and initialize its drawing (IMGUI) function in place: By default the last token of the path is used as display name if no label is provided. Var provider = new SettingsProvider("Project/M圜ustomIMGUISettings", SettingsScope.Project) Second parameter is the scope of this setting: it only appears in the Project Settings window. First parameter is the path in the Settings window. Public static SettingsProvider CreateM圜ustomSettingsProvider() Static class M圜ustomSettingsIMGUIRegister Register a SettingsProvider using IMGUI for the drawing framework: Return new SerializedObject(GetOrCreateSettings()) Internal static SerializedObject GetSerializedSettings() Settings.m_SomeString = "The answer to the universe" ĪssetDatabase.CreateAsset(settings, k_M圜ustomSettingsPath) Settings = ScriptableObject.CreateInstance() Var settings = AssetDatabase.LoadAssetAtPath(k_M圜ustomSettingsPath) Internal static M圜ustomSettings GetOrCreateSettings() Public const string k_M圜ustomSettingsPath = "Assets/ Editor/M圜ustomSettings.asset" ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |