public static void RenderGuiAndPersistInput(ProjectEditorPreferenceDefinitionBase preferenceDefinition, GUIStyle style, params GUILayoutOption[] layoutOptions) { EditorGUI.BeginChangeCheck(); if (!GlobalPrefKeyToValueMap.TryGetValue(preferenceDefinition.PreferenceKey, out var currentValue)) { currentValue = preferenceDefinition.GetEditorPersistedValueOrDefault(); } var newValue = preferenceDefinition.RenderEditorAndCaptureInput(currentValue, style, layoutOptions); GlobalPrefKeyToValueMap[preferenceDefinition.PreferenceKey] = newValue; if (EditorGUI.EndChangeCheck()) { preferenceDefinition.SetEditorPersistedValue(newValue); } }
public static void RenderGuiAndPersistInput(ProjectEditorPreferenceDefinitionBase preferenceDefinition) => RenderGuiAndPersistInput(preferenceDefinition, null, new GUILayoutOption[0]);