private void CreateBoolToggle(bool val, FieldInfo field, GameObject panel) { Toggle toggle = optionsPanel.AddToggleToPanel(panel, field.GetObjectDisplayText(), val); toggle.onValueChanged.AddListener(b => field.SetValue(GetSettingObject(field), b)); }