1
This commit is contained in:
@@ -25,17 +25,42 @@ namespace BITKit.UX.Settings
|
||||
_localizationService = localizationService;
|
||||
_value = _valueWrapper.Value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
[UXBindPath("settings-container")]
|
||||
private VisualElement _settingsContainer;
|
||||
|
||||
[UXBindPath("confirm-button",true)]
|
||||
private Button _confirmButton;
|
||||
|
||||
private void Save()
|
||||
{
|
||||
_valueWrapper.Value = _value;
|
||||
if (_confirmButton is null)
|
||||
{
|
||||
_valueWrapper.Value = _value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnInitiated()
|
||||
{
|
||||
base.OnInitiated();
|
||||
|
||||
if (_confirmButton is not null)
|
||||
{
|
||||
_confirmButton.clicked += OnConfirmButtonOnclicked;
|
||||
}
|
||||
|
||||
Rebuild();
|
||||
}
|
||||
|
||||
private void OnConfirmButtonOnclicked()
|
||||
{
|
||||
_valueWrapper.Value = _value;
|
||||
}
|
||||
|
||||
private void Rebuild()
|
||||
{
|
||||
_settingsContainer.Clear();
|
||||
foreach (var propertyInfo in typeof(TValue).GetProperties())
|
||||
{
|
||||
@@ -128,12 +153,26 @@ namespace BITKit.UX.Settings
|
||||
return enumField;
|
||||
}
|
||||
break;
|
||||
case var type when type == typeof(int2):
|
||||
{
|
||||
var vector2Field = _settingsContainer.Create<Vector2Field>();
|
||||
vector2Field.label = _localizationService.GetLocalizedString(name);
|
||||
var int2Value = value.As<int2>();
|
||||
vector2Field.value = new Vector2(int2Value.x, int2Value.y);
|
||||
vector2Field.RegisterValueChangedCallback(x =>
|
||||
{
|
||||
propertyInfo.SetValue(_value, new int2((int)x.newValue.x, (int)x.newValue.y));
|
||||
Save();
|
||||
});
|
||||
return vector2Field;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user