Exemplo n.º 1
0
        public void OnValueChanged(string newValue)
        {
            var fieldInfo = CurrentOptions.GetType().GetField(targetOption);
            var value     = System.Enum.Parse(fieldInfo.FieldType, newValue);

            fieldInfo.SetValue(CurrentOptions, value);
        }
        public override void Awake()
        {
            base.Awake();

            _colorPicker = GetComponentInChildren <ColorPicker>();
            _colorPicker.onValueChanged.AddListener(OnValueChanged);

            _colorPicker.CurrentColor = (Color)CurrentOptions.GetType().GetField(targetOption).GetValue(CurrentOptions);
        }
Exemplo n.º 3
0
        public override void Awake()
        {
            base.Awake();

            _toggle = GetComponentInChildren <Toggle>();
            _toggle.onValueChanged.AddListener(OnValueChanged);

            _toggle.isOn = (bool)CurrentOptions.GetType().GetField(targetOption).GetValue(CurrentOptions);
        }
Exemplo n.º 4
0
        public void OnValueChangedZ(string newValue)
        {
            var currentValue = (Vector3)CurrentOptions.GetType().GetField(targetOption).GetValue(CurrentOptions);

            currentValue.z = float.Parse(newValue);
            var fieldInfo = CurrentOptions.GetType().GetField(targetOption);

            fieldInfo.SetValue(CurrentOptions, currentValue);
        }
Exemplo n.º 5
0
        public void OnValueChanged(float newValue)
        {
            var fieldInfo = CurrentOptions.GetType().GetField(targetOption);

            if (_slider.wholeNumbers) // ints
            {
                fieldInfo.SetValue(CurrentOptions, (int)newValue);
            }
            else // floats
            {
                fieldInfo.SetValue(CurrentOptions, newValue);
            }
        }
Exemplo n.º 6
0
        public override void Awake()
        {
            base.Awake();

            _carousel = GetComponentInChildren <UICarousel>();
            _carousel.onValueChanged += OnValueChanged;

            var fieldInfo    = CurrentOptions.GetType().GetField(targetOption);
            var defaultValue = fieldInfo.GetValue(CurrentOptions);
            var allValues    = System.Enum.GetNames(fieldInfo.FieldType).ToList();

            _carousel.SetOptions(allValues);
            _carousel.SetCurrentText(defaultValue.ToString());
        }
Exemplo n.º 7
0
        // Start is called before the first frame update
        public override void Awake()
        {
            base.Awake();

            inputFieldX.onEndEdit.AddListener(OnValueChangedX);
            inputFieldY.onEndEdit.AddListener(OnValueChangedY);
            inputFieldZ.onEndEdit.AddListener(OnValueChangedZ);

            var currentValue = (Vector3)CurrentOptions.GetType().GetField(targetOption).GetValue(CurrentOptions);

            inputFieldX.text = currentValue.x.ToString("0");
            inputFieldY.text = currentValue.y.ToString("0");
            inputFieldZ.text = currentValue.z.ToString("0");
        }
Exemplo n.º 8
0
        public override void Awake()
        {
            base.Awake();

            _slider = GetComponentInChildren <Slider>();
            _slider.onValueChanged.AddListener(OnValueChanged);

            try
            {
                if (_slider.wholeNumbers) // ints
                {
                    _slider.value = (int)CurrentOptions.GetType().GetField(targetOption).GetValue(CurrentOptions);
                }
                else // floats
                {
                    _slider.value = (float)CurrentOptions.GetType().GetField(targetOption).GetValue(CurrentOptions);
                }
            }
            catch (Exception e)
            {
                Debug.LogError($"Unable to set slider value for option: {targetOption}");
            }
        }
 public void OnValueChanged(Color newValue)
 {
     CurrentOptions.GetType().GetField(targetOption).SetValue(CurrentOptions, newValue);
 }