コード例 #1
0
 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");
     }
 }
コード例 #2
0
 protected override void Start()
 {
     base.Start();
     if (CheckBox != null)
     {
         CheckBox.OnValueChangedAsObservable()
         .Subscribe(v => SettingsBag.GetType().GetField(FieldName).SetValue(SettingsBag, v));
     }
 }
コード例 #3
0
        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)));
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        private bool IsDirectory()
        {
            var attr = SettingsBag.GetType().GetField(FieldName).GetCustomAttribute <PathAttribute>();

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