1
This commit is contained in:
@@ -52,7 +52,7 @@ namespace BITKit.Entities
|
|||||||
{
|
{
|
||||||
while (_onAddQueue.TryDequeue(out var entity))
|
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);
|
OnAdd?.Invoke(entity);
|
||||||
MakeCache(entity);
|
MakeCache(entity);
|
||||||
}
|
}
|
||||||
|
@@ -113,6 +113,19 @@ namespace BITKit
|
|||||||
}
|
}
|
||||||
return false;
|
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)
|
public static bool Contains<T>(IEnumerable<T> a, IEnumerable<T> b)
|
||||||
{
|
{
|
||||||
foreach (var x in b)
|
foreach (var x in b)
|
||||||
|
@@ -5,6 +5,9 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Cysharp.Threading.Tasks;
|
using Cysharp.Threading.Tasks;
|
||||||
using Unity.Mathematics;
|
using Unity.Mathematics;
|
||||||
|
#if UNITY_5_3_OR_NEWER
|
||||||
|
using UnityEngine;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace BITKit.Tween
|
namespace BITKit.Tween
|
||||||
{
|
{
|
||||||
@@ -68,7 +71,13 @@ namespace BITKit.Tween
|
|||||||
//BIT4Log.Log<TweenSequence>($"已创建Tween,from:[{from}]to:[{to}]duration:[{duration}]delta:[{delta}]");
|
//BIT4Log.Log<TweenSequence>($"已创建Tween,from:[{from}]to:[{to}]duration:[{duration}]delta:[{delta}]");
|
||||||
while (t < 1 && cancellationToken.IsCancellationRequested is false)
|
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);
|
var next = func(from, to, t);
|
||||||
#if UNITY_5_3_OR_NEWER
|
#if UNITY_5_3_OR_NEWER
|
||||||
await UniTask.NextFrame(cancellationToken);
|
await UniTask.NextFrame(cancellationToken);
|
||||||
|
@@ -854,6 +854,15 @@
|
|||||||
"processors": "",
|
"processors": "",
|
||||||
"interactions": "",
|
"interactions": "",
|
||||||
"initialStateCheck": false
|
"initialStateCheck": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Map",
|
||||||
|
"type": "Button",
|
||||||
|
"id": "fa290d94-fe08-4c71-823d-0efe096552ff",
|
||||||
|
"expectedControlType": "",
|
||||||
|
"processors": "",
|
||||||
|
"interactions": "",
|
||||||
|
"initialStateCheck": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"bindings": [
|
"bindings": [
|
||||||
@@ -1197,6 +1206,28 @@
|
|||||||
"action": "Cancel",
|
"action": "Cancel",
|
||||||
"isComposite": false,
|
"isComposite": false,
|
||||||
"isPartOfComposite": 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
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@@ -17,5 +17,18 @@ namespace BITKit
|
|||||||
Object.Destroy(t);
|
Object.Destroy(t);
|
||||||
return 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -33,7 +33,7 @@ namespace BITKit.Pool
|
|||||||
{
|
{
|
||||||
if (obj is not Component component) continue;
|
if (obj is not Component component) continue;
|
||||||
if (!hashset.Add(component.gameObject)) continue;
|
if (!hashset.Add(component.gameObject)) continue;
|
||||||
if (component.gameObject)
|
if (component)
|
||||||
Object.Destroy(component.gameObject);
|
Object.Destroy(component.gameObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -87,6 +87,9 @@ namespace BITKit.Pool
|
|||||||
if (asset is Object o)
|
if (asset is Object o)
|
||||||
{
|
{
|
||||||
var instance = Object.Instantiate(o);
|
var instance = Object.Instantiate(o);
|
||||||
|
|
||||||
|
instance.name = path;
|
||||||
|
|
||||||
list.Add(instance);
|
list.Add(instance);
|
||||||
UsingPool.GetOrCreate(path).Add(instance);
|
UsingPool.GetOrCreate(path).Add(instance);
|
||||||
ReadyPool.GetOrCreate(path);
|
ReadyPool.GetOrCreate(path);
|
||||||
|
@@ -25,17 +25,42 @@ namespace BITKit.UX.Settings
|
|||||||
_localizationService = localizationService;
|
_localizationService = localizationService;
|
||||||
_value = _valueWrapper.Value;
|
_value = _valueWrapper.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[UXBindPath("settings-container")]
|
[UXBindPath("settings-container")]
|
||||||
private VisualElement _settingsContainer;
|
private VisualElement _settingsContainer;
|
||||||
|
|
||||||
|
[UXBindPath("confirm-button",true)]
|
||||||
|
private Button _confirmButton;
|
||||||
|
|
||||||
private void Save()
|
private void Save()
|
||||||
{
|
{
|
||||||
_valueWrapper.Value = _value;
|
if (_confirmButton is null)
|
||||||
|
{
|
||||||
|
_valueWrapper.Value = _value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnInitiated()
|
protected override void OnInitiated()
|
||||||
{
|
{
|
||||||
base.OnInitiated();
|
base.OnInitiated();
|
||||||
|
|
||||||
|
if (_confirmButton is not null)
|
||||||
|
{
|
||||||
|
_confirmButton.clicked += OnConfirmButtonOnclicked;
|
||||||
|
}
|
||||||
|
|
||||||
|
Rebuild();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnConfirmButtonOnclicked()
|
||||||
|
{
|
||||||
|
_valueWrapper.Value = _value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Rebuild()
|
||||||
|
{
|
||||||
_settingsContainer.Clear();
|
_settingsContainer.Clear();
|
||||||
foreach (var propertyInfo in typeof(TValue).GetProperties())
|
foreach (var propertyInfo in typeof(TValue).GetProperties())
|
||||||
{
|
{
|
||||||
@@ -128,12 +153,26 @@ namespace BITKit.UX.Settings
|
|||||||
return enumField;
|
return enumField;
|
||||||
}
|
}
|
||||||
break;
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "Tests",
|
"name": "BITKit.Tests",
|
||||||
"rootNamespace": "",
|
"rootNamespace": "",
|
||||||
"references": [
|
"references": [
|
||||||
"UnityEngine.TestRunner",
|
"UnityEngine.TestRunner",
|
||||||
|
Reference in New Issue
Block a user