This commit is contained in:
CortexCore
2025-08-03 02:28:50 +08:00
parent ecae0f809c
commit c3f0a8e840
8 changed files with 114 additions and 6 deletions

View File

@@ -854,6 +854,15 @@
"processors": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "Map",
"type": "Button",
"id": "fa290d94-fe08-4c71-823d-0efe096552ff",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
}
],
"bindings": [
@@ -1197,6 +1206,28 @@
"action": "Cancel",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "e3cd8458-c141-4a70-b841-88fa0711d0f1",
"path": "<Keyboard>/capsLock",
"interactions": "",
"processors": "",
"groups": "",
"action": "Map",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "a433d70f-d2ca-42a8-ab45-cf68424f6155",
"path": "<Keyboard>/m",
"interactions": "",
"processors": "",
"groups": "",
"action": "Map",
"isComposite": false,
"isPartOfComposite": false
}
]
},

View File

@@ -17,5 +17,18 @@ namespace BITKit
Object.Destroy(t);
return t;
}
public static int RemoveComponentsInChildren<T>(this GameObject gameObject) where T :Component
{
var count = 0;
foreach (var x in gameObject.GetComponentsInChildren<T>())
{
if (!x) continue;
Object.Destroy(x);
count++;
}
return count;
}
}
}

View File

@@ -33,7 +33,7 @@ namespace BITKit.Pool
{
if (obj is not Component component) continue;
if (!hashset.Add(component.gameObject)) continue;
if (component.gameObject)
if (component)
Object.Destroy(component.gameObject);
}
}
@@ -87,6 +87,9 @@ namespace BITKit.Pool
if (asset is Object o)
{
var instance = Object.Instantiate(o);
instance.name = path;
list.Add(instance);
UsingPool.GetOrCreate(path).Add(instance);
ReadyPool.GetOrCreate(path);

View File

@@ -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;
}
}
}
}
}