public ConfigSet GetConfigSet(INotifyPropertyChanged o) { var properties = new List <ConfigProperty>(); //look for attribute foreach (var property in o.GetType().GetProperties()) { foreach (var attribute in property.GetCustomAttributes(true)) { var configSlider = attribute as ConfigSlider; if (configSlider != null) { var sliderConfigProperty = new SliderConfigProperty(); sliderConfigProperty.customName = configSlider.customName; sliderConfigProperty.min = configSlider.min; sliderConfigProperty.max = configSlider.max; sliderConfigProperty.o = o; sliderConfigProperty.property = property; properties.Add(sliderConfigProperty); LoadPlayerPref(o, property.Name); continue; } var config = attribute as Config; if (config != null) { if (property.PropertyType == typeof(bool)) { var toggleConfigProperty = new ToggleConfigProperty(); toggleConfigProperty.customName = config.customName; toggleConfigProperty.o = o; toggleConfigProperty.property = property; properties.Add(toggleConfigProperty); LoadPlayerPref(o, property.Name); continue; } var configProperty = new ConfigProperty(); configProperty.customName = config.customName; configProperty.o = o; configProperty.property = property; properties.Add(configProperty); LoadPlayerPref(o, property.Name); } } } //store them with their object if (properties.Count == 0) { return(null); } o.PropertyChanged += OnPropertyChanged; var configSet = new ConfigSet(); configSet.o = o; configSet.properties = properties.ToArray(); return(configSet); }
void AddSliderItem(Panel panel, SliderConfigProperty sliderProperty) { var sliderItem = panel.AddSlider(GetConfigPropertyName(sliderProperty)); sliderItem.Bind(sliderProperty.o, sliderProperty.property); }