Documentation for the Unity C# Library
Loading...
Searching...
No Matches
ItemIDsSettingsIMGUIRegister.cs
Go to the documentation of this file.
1#if UNITY_EDITOR
2using System.Collections.Generic;
3using UnityEditor;
4
5static class ItemIDsSettingsIMGUIRegister
6{
7 [SettingsProvider]
8 public static SettingsProvider CreateMyCustomSettingsProvider()
9 {
10 // First parameter is the path in the Settings window.
11 // Second parameter is the scope of this setting: it only appears in the Project Settings window.
12 var provider = new SettingsProvider("Project/ItemIDsSettings", SettingsScope.Project)
13 {
14 // By default the last token of the path is used as display name if no label is provided.
15 label = "Items",
16
17 // Create the SettingsProvider and initialize its drawing (IMGUI) function in place:
18 guiHandler = (searchContext) =>
19 {
20 var settings = ItemIDsSettings.GetSerializedSettings();
21 EditorGUILayout.PropertyField(settings.FindProperty("itemIds"));
22
23 settings.ApplyModifiedProperties();
24 EditorUtility.SetDirty(settings.targetObject);
25 },
26
27 // Populate the search keywords to enable smart search filtering and label highlighting:
28 keywords = new HashSet<string>(new[] {"Items", "Names"})
29 };
30
31 return provider;
32 }
33}
34#endif