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

@@ -52,7 +52,7 @@ namespace BITKit.Entities
{
while (_onAddQueue.TryDequeue(out var entity))
{
if(_addingEntities.Remove(entity) is false)continue;
if(_addingEntities.Remove(entity) is false || entity.CancellationToken.IsCancellationRequested)continue;
OnAdd?.Invoke(entity);
MakeCache(entity);
}

View File

@@ -113,6 +113,19 @@ namespace BITKit
}
return false;
}
public static bool Contains<T>(this Span<T> span, T value)
{
foreach (var t in span)
{
if (Equals(t, value))
return true;
}
return false;
}
public static bool Contains<T>(IEnumerable<T> a, IEnumerable<T> b)
{
foreach (var x in b)

View File

@@ -5,6 +5,9 @@ using System.Threading;
using System.Threading.Tasks;
using Cysharp.Threading.Tasks;
using Unity.Mathematics;
#if UNITY_5_3_OR_NEWER
using UnityEngine;
#endif
namespace BITKit.Tween
{
@@ -68,7 +71,13 @@ namespace BITKit.Tween
//BIT4Log.Log<TweenSequence>($"已创建Tween,from:[{from}]to:[{to}]duration:[{duration}]delta:[{delta}]");
while (t < 1 && cancellationToken.IsCancellationRequested is false)
{
t = math.clamp(t + delta*BITApp.Time.DeltaTime, 0, 1);
var value = t + delta * BITApp.Time.DeltaTime;
#if UNITY_5_3_OR_NEWER
value = t+ delta * Time.deltaTime;
#endif
t = math.clamp(value, 0, 1);
var next = func(from, to, t);
#if UNITY_5_3_OR_NEWER
await UniTask.NextFrame(cancellationToken);

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

@@ -26,16 +26,41 @@ namespace BITKit.UX.Settings
_value = _valueWrapper.Value;
}
[UXBindPath("settings-container")]
private VisualElement _settingsContainer;
[UXBindPath("confirm-button",true)]
private Button _confirmButton;
private void Save()
{
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;
}
}
}
}
}

View File

@@ -1,5 +1,5 @@
{
"name": "Tests",
"name": "BITKit.Tests",
"rootNamespace": "",
"references": [
"UnityEngine.TestRunner",