private void OnTextChanged(string text)
 {
     if (FieldType == typeof(int))
     {
         if (int.TryParse(text, out int val))
         {
             SettingsBag.GetType().GetField(FieldName).SetValue(SettingsBag, val);
         }
     }
     else if (FieldType == typeof(float))
     {
         if (float.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out float val))
         {
             SettingsBag.GetType().GetField(FieldName).SetValue(SettingsBag, val);
         }
     }
     else if (FieldType == typeof(string))
     {
         SettingsBag.GetType().GetField(FieldName).SetValue(SettingsBag, text);
     }
     else
     {
         throw new NotSupportedException("Other field types not implemented yet");
     }
 }
 protected override void Start()
 {
     base.Start();
     if (CheckBox != null)
     {
         CheckBox.OnValueChangedAsObservable()
         .Subscribe(v => SettingsBag.GetType().GetField(FieldName).SetValue(SettingsBag, v));
     }
 }
        public void Generate(SettingsBag settings)
        {
            _fields.ForEach(f => Destroy(f != null ? f.gameObject : null));

            settings.GetType()
            .GetFields(BindingFlags.Public | BindingFlags.Instance)
            .Where(f => f.GetCustomAttribute <NotShowAttribute>() == null)
            .ToList()
            .ForEach((f => AddField(f, settings)));
        }
        protected override void Start()
        {
            var input = GetComponent <InputWithBrowse>();

            base.Start();
            if (input != null && IsDirectory())
            {
                input.FolderMode = true;
            }
            else if (input != null)
            {
                input.Filters = SettingsBag.GetType().GetField(FieldName).GetCustomAttribute <PathAttribute>().Extensions;
            }

            Field.OnValueChangedAsObservable().Subscribe(OnTextChanged);
        }
        private bool IsDirectory()
        {
            var attr = SettingsBag.GetType().GetField(FieldName).GetCustomAttribute <PathAttribute>();

            return(attr != null && attr.PathType == PathAttribute.PathTypes.Directory);
        }