public override void BuildUI(OptionInfo option, GameObject element) { var control = element.GetComponentInChildren <UnityEngine.UI.Toggle>(); control.isOn = option.GetPropertyValue <bool>(); control.onValueChanged.AddListener(value => option.SetPropertyValue(value)); }
public override void BuildUI(OptionInfo option, GameObject element) { var control = element.GetComponentInChildren <UnityEngine.UI.InputField>(); control.text = option.GetPropertyValue <string>(); control.onValueChanged.AddListener(value => option.SetPropertyValue(value)); }
public override void BuildUI(OptionInfo option, GameObject element) { var control = element.GetComponentInChildren <UnityEngine.UI.Dropdown>(); control.options = Options.Select(opt => new UnityEngine.UI.Dropdown.OptionData(opt)).ToList(); var valueIndex = GetInitialIndex(option.GetPropertyValue <string>()); if (valueIndex >= 0) { control.value = valueIndex; } else { control.value = 0; SaveValue(option, Options[0], 0); } control.onValueChanged.AddListener(index => { if (index < 0 || index >= Options.Count) { control.value = 0; return; } SaveValue(option, Options[index], index); }); }
public override void BuildUI(OptionInfo option, GameObject element) { var sliderObj = element.GetComponentInChildren <UnityEngine.UI.Slider>(); sliderObj.minValue = Min; sliderObj.maxValue = Max; sliderObj.value = option.GetPropertyValue <float>(); sliderObj.onValueChanged.AddListener(value => option.SetPropertyValue(value)); }