设备连接界面断开逻辑调整
This commit is contained in:
parent
46b6c7fa01
commit
6b3dd70c61
Binary file not shown.
@ -544,5 +544,10 @@ namespace Assets.Scripts.Devices.Ant
|
|||||||
channel.closeChannel(500);
|
channel.closeChannel(500);
|
||||||
channel.unassignChannel(500);
|
channel.unassignChannel(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Remove(AbstractAntDevice device)
|
||||||
|
{
|
||||||
|
discoveredDevices.Remove(device);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,6 +42,18 @@ namespace Assets.Scripts.Devices.Ant
|
|||||||
return AntConnector.Instance().discoveredDevices;
|
return AntConnector.Instance().discoveredDevices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Refresh()
|
||||||
|
{
|
||||||
|
var list = AntConnector.Instance().discoveredDevices.ToList();
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
if (item.State == Ant.DeviceState.Disconnected)
|
||||||
|
{
|
||||||
|
AntConnector.Instance().Remove(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void StartScan()
|
public override void StartScan()
|
||||||
{
|
{
|
||||||
//throw new NotImplementedException();
|
//throw new NotImplementedException();
|
||||||
|
|||||||
@ -183,6 +183,19 @@ namespace Assets.Scripts.Devices.Ble
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Refresh()
|
||||||
|
{
|
||||||
|
var list = discoveredDevices.ToList();
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
if (item.Value.State == Ant.DeviceState.Disconnected)
|
||||||
|
{
|
||||||
|
item.Value.Dispose();
|
||||||
|
discoveredDevices.Remove(item.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清除未连接的设备
|
/// 清除未连接的设备
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -24,7 +24,7 @@ namespace Assets.Scripts.Devices
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public abstract void Refresh();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -129,14 +129,35 @@ public class RowerDeviceView : MonoBehaviour
|
|||||||
UIManager.AddEvent(gameObject, EventTriggerType.PointerClick, b =>
|
UIManager.AddEvent(gameObject, EventTriggerType.PointerClick, b =>
|
||||||
{
|
{
|
||||||
if (!mPairButton.activeInHierarchy && !mDisconnectButton.activeInHierarchy) return;
|
if (!mPairButton.activeInHierarchy && !mDisconnectButton.activeInHierarchy) return;
|
||||||
connectButtonClick();
|
var device = GetDevice();
|
||||||
|
if (device != null && device.State == DeviceState.Connected)
|
||||||
|
{
|
||||||
|
UIManager.ShowConfirm("警告", "是否断开该设备?", () =>
|
||||||
|
{
|
||||||
|
device.Disconnect(false);
|
||||||
|
UIManager.CloseConfirm();
|
||||||
|
}, 2, () => {
|
||||||
|
UIManager.CloseConfirm();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
connectButtonClick();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
UIManager.AddEvent(mDisconnectButton, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e => {
|
UIManager.AddEvent(mDisconnectButton, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e => {
|
||||||
//var device = GetDevice();
|
UIManager.ShowConfirm("警告", "是否断开该设备?", () =>
|
||||||
//if(device != null && device.State == DeviceState.Connected)
|
{
|
||||||
//{
|
var device = GetDevice();
|
||||||
// device.Disconnect();
|
if (device != null && device.State == DeviceState.Connected)
|
||||||
//}
|
{
|
||||||
|
device.Disconnect(false);
|
||||||
|
}
|
||||||
|
UIManager.CloseConfirm();
|
||||||
|
}, 2, () => {
|
||||||
|
UIManager.CloseConfirm();
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
|
||||||
#if UNITY_IOS || UNITY_ANDROID
|
#if UNITY_IOS || UNITY_ANDROID
|
||||||
var obj = Resources.Load("UI/Prefab/Device/Mobile/ConnectDeviceModal");
|
var obj = Resources.Load("UI/Prefab/Device/Mobile/ConnectDeviceModal");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user