修改连接设备界面;修改大地图在panel上缩放大地图也缩放的问题
This commit is contained in:
1 parent
541aefe4dd
commit
25c866d090
20 files changed
+744
-85
No files matched your search
@@ -95,7 +95,7 @@ namespace Assets.Scripts.Devices.Ble
|
||||
if (discoveredDevices.ContainsKey(device.Peripheral.Address))
|
||||
{
|
||||
discoveredDevices[device.Peripheral.Address].SignalStrength = device.Rssi;
|
||||
//Debug.Log($"设备{ device.Peripheral.Name }信号量:{ device.Rssi }");
|
||||
Debug.Log($"设备{ device.Peripheral.Name }信号量:{ device.Rssi }");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Assets.Scripts.Ble.Scan
|
||||
public class BleAdvertisementInfo
|
||||
{
|
||||
public BlePeripheralInfo Peripheral { get; }
|
||||
public int Rssi { get; }
|
||||
public int Rssi { get; set; }
|
||||
|
||||
public SensorType SensorType { get; internal set; }
|
||||
public BleAdvertisementInfo(BlePeripheralInfo peripheral, int rssi, bool connectible, List<Guid> services, byte[] manufactureData, SensorType sensor)
|
||||
|
||||
@@ -155,6 +155,7 @@ namespace Assets.Scripts.Ble
|
||||
return;
|
||||
}
|
||||
pCache[addressStr].SensorType = sensor;
|
||||
pCache[addressStr].Rssi = rssi;
|
||||
//Debug.Log(sensor);
|
||||
//pCache[address.ToString()].SensorType = sensor;
|
||||
|
||||
|
||||
@@ -21,66 +21,52 @@ namespace Assets.Scripts.Ble.Win
|
||||
this.mPtr = WclBleGattClient.WCLGattClientCreate(this.CConnectEvent, this.CDisconnectEvent, this.FCharacteristicChangedEvent);
|
||||
}
|
||||
|
||||
// Token: 0x06002086 RID: 8326
|
||||
[DllImport("WclBlePluginCPP.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
[return: MarshalAs(UnmanagedType.I4)]
|
||||
private static extern int WCLGattClientConnect([MarshalAs(UnmanagedType.SysInt)][In] IntPtr Client, [MarshalAs(UnmanagedType.SysInt)][In] IntPtr Radio, [MarshalAs(UnmanagedType.I8)][In] long Address);
|
||||
|
||||
// Token: 0x06002087 RID: 8327
|
||||
[DllImport("WclBlePluginCPP.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
[return: MarshalAs(UnmanagedType.SysInt)]
|
||||
private static extern IntPtr WCLGattClientCreate([MarshalAs(UnmanagedType.FunctionPtr)][In] WclBleGattClient.GATTCLIENT_CONNECT OnConnect, [MarshalAs(UnmanagedType.FunctionPtr)][In] WclBleGattClient.GATTCLIENT_DISCONNECT OnDisconnect, [MarshalAs(UnmanagedType.FunctionPtr)][In] WclBleGattClient.GATTCLIENT_ONCHANGED OnChanged);
|
||||
|
||||
// Token: 0x06002088 RID: 8328
|
||||
[DllImport("WclBlePluginCPP.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
private static extern void WCLGattClientDestroy([MarshalAs(UnmanagedType.SysInt)][In] IntPtr Client);
|
||||
|
||||
// Token: 0x06002089 RID: 8329
|
||||
[DllImport("WclBlePluginCPP.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
[return: MarshalAs(UnmanagedType.I4)]
|
||||
private static extern int WCLGattClientDisconnect([MarshalAs(UnmanagedType.SysInt)][In] IntPtr Client);
|
||||
|
||||
// Token: 0x0600208A RID: 8330
|
||||
[DllImport("WclBlePluginCPP.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
private static extern void WCLGattClientFreeMem([MarshalAs(UnmanagedType.SysInt)][In] IntPtr pMem);
|
||||
|
||||
// Token: 0x0600208B RID: 8331
|
||||
[DllImport("WclBlePluginCPP.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
[return: MarshalAs(UnmanagedType.I4)]
|
||||
private static extern int WCLGattClientGetCharacteristics([MarshalAs(UnmanagedType.SysInt)][In] IntPtr Client, [In] ref GattService Service, [In][Out] ref GattCharacteristics Chars);
|
||||
|
||||
// Token: 0x0600208C RID: 8332
|
||||
[DllImport("WclBlePluginCPP.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
[return: MarshalAs(UnmanagedType.I4)]
|
||||
private static extern int WCLGattClientGetServices([MarshalAs(UnmanagedType.SysInt)][In] IntPtr Client, [In][Out] ref GattServices Services);
|
||||
|
||||
// Token: 0x0600208D RID: 8333
|
||||
[DllImport("WclBlePluginCPP.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
[return: MarshalAs(UnmanagedType.U4)]
|
||||
private static extern WclBleGattClientState WCLGattClientGetState([MarshalAs(UnmanagedType.SysInt)][In] IntPtr Client);
|
||||
|
||||
// Token: 0x0600208E RID: 8334
|
||||
[DllImport("WclBlePluginCPP.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
[return: MarshalAs(UnmanagedType.I4)]
|
||||
private static extern int WCLGattClientReadCharacteristicValue([MarshalAs(UnmanagedType.SysInt)][In] IntPtr Client, [In] ref GattCharacteristic Char, [MarshalAs(UnmanagedType.SysInt)][In][Out] ref IntPtr ppValue, [MarshalAs(UnmanagedType.U4)][In][Out] ref uint pSize);
|
||||
|
||||
// Token: 0x0600208F RID: 8335
|
||||
[DllImport("WclBlePluginCPP.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
[return: MarshalAs(UnmanagedType.I4)]
|
||||
private static extern int WCLGattClientSubscribeCharacteristic([MarshalAs(UnmanagedType.SysInt)][In] IntPtr Client, [In] ref GattCharacteristic Char);
|
||||
|
||||
// Token: 0x06002090 RID: 8336
|
||||
[DllImport("WclBlePluginCPP.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
[return: MarshalAs(UnmanagedType.I4)]
|
||||
private static extern int WCLGattClientUnsubscribeCharacteristic([MarshalAs(UnmanagedType.SysInt)][In] IntPtr Client, [In] ref GattCharacteristic Char);
|
||||
|
||||
// Token: 0x06002091 RID: 8337
|
||||
[DllImport("WclBlePluginCPP.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
[return: MarshalAs(UnmanagedType.I4)]
|
||||
private static extern int WCLGattClientWriteCharacteristicValue([MarshalAs(UnmanagedType.SysInt)][In] IntPtr Client, [In] ref GattCharacteristic Char, [MarshalAs(UnmanagedType.SysInt)][In] IntPtr pValue, [MarshalAs(UnmanagedType.U4)][In] uint Size);
|
||||
|
||||
// Token: 0x170005D4 RID: 1492
|
||||
// (get) Token: 0x06002092 RID: 8338 RVA: 0x00087790 File Offset: 0x00085990
|
||||
public WclBleGattClientState State
|
||||
{
|
||||
get
|
||||
@@ -89,7 +75,6 @@ namespace Assets.Scripts.Ble.Win
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06002093 RID: 8339 RVA: 0x000877A4 File Offset: 0x000859A4
|
||||
public void Connect()
|
||||
{
|
||||
if (this.mPtr != IntPtr.Zero)
|
||||
@@ -102,7 +87,6 @@ namespace Assets.Scripts.Ble.Win
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06002094 RID: 8340 RVA: 0x000877F4 File Offset: 0x000859F4
|
||||
public void Disconnect()
|
||||
{
|
||||
if (this.mPtr != IntPtr.Zero)
|
||||
@@ -113,7 +97,6 @@ namespace Assets.Scripts.Ble.Win
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06002095 RID: 8341 RVA: 0x00087864 File Offset: 0x00085A64
|
||||
public int DiscoverCharacteristics(GattService service, out GattCharacteristics characteristics)
|
||||
{
|
||||
characteristics = new GattCharacteristics
|
||||
@@ -124,7 +107,6 @@ namespace Assets.Scripts.Ble.Win
|
||||
return WclBleGattClient.WCLGattClientGetCharacteristics(this.mPtr, ref service, ref characteristics);
|
||||
}
|
||||
|
||||
// Token: 0x06002096 RID: 8342 RVA: 0x000878B0 File Offset: 0x00085AB0
|
||||
public int DiscoverServices(out GattServices services)
|
||||
{
|
||||
services = new GattServices
|
||||
@@ -135,7 +117,6 @@ namespace Assets.Scripts.Ble.Win
|
||||
return WclBleGattClient.WCLGattClientGetServices(this.mPtr, ref services);
|
||||
}
|
||||
|
||||
// Token: 0x06002097 RID: 8343 RVA: 0x000878F8 File Offset: 0x00085AF8
|
||||
public int ReadCharacteristicValue(GattCharacteristic characteristic, out byte[] value)
|
||||
{
|
||||
value = null;
|
||||
@@ -151,13 +132,11 @@ namespace Assets.Scripts.Ble.Win
|
||||
return num2;
|
||||
}
|
||||
|
||||
// Token: 0x06002098 RID: 8344 RVA: 0x00087953 File Offset: 0x00085B53
|
||||
public int SubscribeCharacteristic(GattCharacteristic characteristic)
|
||||
{
|
||||
return WclBleGattClient.WCLGattClientSubscribeCharacteristic(this.mPtr, ref characteristic);
|
||||
}
|
||||
|
||||
// Token: 0x06002099 RID: 8345 RVA: 0x00087968 File Offset: 0x00085B68
|
||||
public int WriteCharacteristic(GattCharacteristic characteristic, byte[] value)
|
||||
{
|
||||
IntPtr intPtr;
|
||||
@@ -179,7 +158,6 @@ namespace Assets.Scripts.Ble.Win
|
||||
return result;
|
||||
}
|
||||
|
||||
// Token: 0x0600209A RID: 8346 RVA: 0x000879D4 File Offset: 0x00085BD4
|
||||
public void Dispose()
|
||||
{
|
||||
WclBleGattClient.WCLGattClientDestroy(this.mPtr);
|
||||
@@ -190,7 +168,6 @@ namespace Assets.Scripts.Ble.Win
|
||||
this.FCharacteristicChangedEvent = null;
|
||||
}
|
||||
|
||||
// Token: 0x0600209B RID: 8347 RVA: 0x00087A0C File Offset: 0x00085C0C
|
||||
private void OnCharacteristicChanged(IntPtr sender, ushort handle, IntPtr pValue, uint valueLen)
|
||||
{
|
||||
//Debug.Log("char changed");
|
||||
@@ -213,7 +190,6 @@ namespace Assets.Scripts.Ble.Win
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600209C RID: 8348 RVA: 0x00087A80 File Offset: 0x00085C80
|
||||
private void OnConnected(IntPtr client, int error)
|
||||
{
|
||||
try
|
||||
@@ -232,7 +208,6 @@ namespace Assets.Scripts.Ble.Win
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600209D RID: 8349 RVA: 0x00087AD0 File Offset: 0x00085CD0
|
||||
private void OnDisconnected(IntPtr client, int reason)
|
||||
{
|
||||
try
|
||||
@@ -249,53 +224,34 @@ namespace Assets.Scripts.Ble.Win
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0400130B RID: 4875
|
||||
public WclBleGattClient.GattCharacteristicChanged CharacteristicChanged;
|
||||
|
||||
// Token: 0x0400130C RID: 4876
|
||||
public WclBleGattClient.GattConnectionChanged Connected;
|
||||
|
||||
// Token: 0x0400130D RID: 4877
|
||||
public WclBleGattClient.GattConnectionChanged Disconnected;
|
||||
|
||||
// Token: 0x0400130F RID: 4879
|
||||
private WclBleGattClient.GATTCLIENT_CONNECT CConnectEvent;
|
||||
|
||||
// Token: 0x04001310 RID: 4880
|
||||
private WclBleGattClient.GATTCLIENT_DISCONNECT CDisconnectEvent;
|
||||
|
||||
// Token: 0x04001311 RID: 4881
|
||||
private WclBleGattClient.GATTCLIENT_ONCHANGED FCharacteristicChangedEvent;
|
||||
|
||||
// Token: 0x04001312 RID: 4882
|
||||
private readonly long gattAddress;
|
||||
|
||||
// Token: 0x04001313 RID: 4883
|
||||
private IntPtr mPtr;
|
||||
|
||||
// Token: 0x04001314 RID: 4884
|
||||
private IntPtr rPtr;
|
||||
|
||||
// Token: 0x020008FB RID: 2299
|
||||
// (Invoke) Token: 0x06003F5A RID: 16218
|
||||
public delegate void GattCharacteristicChanged(WclBleGattClient connection, ushort handle, byte[] value);
|
||||
|
||||
// Token: 0x020008FC RID: 2300
|
||||
// (Invoke) Token: 0x06003F5E RID: 16222
|
||||
public delegate void GattConnectionChanged(WclBleGattClient connection, int error);
|
||||
|
||||
// Token: 0x020008FD RID: 2301
|
||||
// (Invoke) Token: 0x06003F62 RID: 16226
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall, SetLastError = false)]
|
||||
private delegate void GATTCLIENT_CONNECT([MarshalAs(UnmanagedType.SysInt)][In] IntPtr Sender, [MarshalAs(UnmanagedType.I4)][In] int Error);
|
||||
|
||||
// Token: 0x020008FE RID: 2302
|
||||
// (Invoke) Token: 0x06003F66 RID: 16230
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall, SetLastError = false)]
|
||||
private delegate void GATTCLIENT_DISCONNECT([MarshalAs(UnmanagedType.SysInt)][In] IntPtr Sender, [MarshalAs(UnmanagedType.I4)][In] int Reason);
|
||||
|
||||
// Token: 0x020008FF RID: 2303
|
||||
// (Invoke) Token: 0x06003F6A RID: 16234
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall, SetLastError = false)]
|
||||
private delegate void GATTCLIENT_ONCHANGED([MarshalAs(UnmanagedType.SysInt)][In] IntPtr Sender, [MarshalAs(UnmanagedType.U2)][In] ushort Handle, [MarshalAs(UnmanagedType.SysInt)][In] IntPtr Value, [MarshalAs(UnmanagedType.U4)][In] uint ValueLen);
|
||||
|
||||
|
||||
@@ -68,12 +68,13 @@ public class MainController : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
UIManager.ShowHomePanel();
|
||||
//UIManager.ShowHomePanel();
|
||||
//UIManager.ShowUserInfoPanel();
|
||||
//UIManager.ShowEditUserPanel();
|
||||
//UIManager.ShowBigMapPanel();
|
||||
//UIManager.ShowEarthPanel();
|
||||
}
|
||||
UIManager.ShowDevicePanel();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
||||
@@ -10,7 +10,9 @@ public class DeviceItem : Selectable, IEventSystemHandler, IPointerClickHandler
|
||||
{
|
||||
private bool isOn;
|
||||
private Text mText;
|
||||
private Text mType;
|
||||
private Image network;
|
||||
private Image signal;
|
||||
private float timer = 0f;
|
||||
public AbstractDevice DeviceInfo
|
||||
{
|
||||
get;set;
|
||||
@@ -19,7 +21,8 @@ public class DeviceItem : Selectable, IEventSystemHandler, IPointerClickHandler
|
||||
protected override void Awake()
|
||||
{
|
||||
mText = this.transform.Find("Name").GetComponent<Text>();
|
||||
mType = this.transform.Find("Type").GetComponent<Text>();
|
||||
network = this.transform.Find("Network").GetComponent<Image>();
|
||||
signal = this.transform.Find("Signal").GetComponent<Image>();
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
@@ -37,10 +40,41 @@ public class DeviceItem : Selectable, IEventSystemHandler, IPointerClickHandler
|
||||
// this.SetSelectedStyle();
|
||||
}
|
||||
|
||||
mType.text = DeviceInfo.Network.ToString();
|
||||
if(DeviceInfo.Network == NetworkType.BLE)
|
||||
{
|
||||
network.sprite = Resources.Load<Sprite>("Images/link_bluetooth_2");
|
||||
}
|
||||
else
|
||||
{
|
||||
signal.enabled = false;
|
||||
}
|
||||
SetSignal();
|
||||
}
|
||||
|
||||
|
||||
private void SetSignal()
|
||||
{
|
||||
if(DeviceInfo == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//Debug.Log(DeviceInfo.SignalStrength);
|
||||
|
||||
var signalValue = DeviceInfo.SignalStrength * -1;
|
||||
if (signalValue >= 0 && signalValue <= 30)
|
||||
{
|
||||
signal.sprite = Resources.Load<Sprite>("Images/Signal_1");
|
||||
}
|
||||
else if (signalValue > 30 && signalValue <= 70)
|
||||
{
|
||||
signal.sprite = Resources.Load<Sprite>("Images/Signal_2");
|
||||
}
|
||||
else if (signalValue > 70 && signalValue <= 97)
|
||||
{
|
||||
signal.sprite = Resources.Load<Sprite>("Images/Signal_3");
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
//base.OnPointerEnter(eventData);
|
||||
@@ -59,6 +93,8 @@ public class DeviceItem : Selectable, IEventSystemHandler, IPointerClickHandler
|
||||
shadow.enabled = true;
|
||||
ColorUtility.TryParseHtmlString("#F93086", out Color color1);
|
||||
shadow.effectColor = color1;
|
||||
|
||||
network.color = color1;
|
||||
}
|
||||
|
||||
public override void Select()
|
||||
@@ -82,7 +118,15 @@ public class DeviceItem : Selectable, IEventSystemHandler, IPointerClickHandler
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
if (timer >= 2)
|
||||
{
|
||||
timer = 0f;
|
||||
|
||||
SetSignal();
|
||||
|
||||
return;
|
||||
}
|
||||
timer += Time.deltaTime;
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
@@ -110,6 +154,7 @@ public class DeviceItem : Selectable, IEventSystemHandler, IPointerClickHandler
|
||||
else
|
||||
{
|
||||
mText.color = Color.white;
|
||||
network.color = Color.white;
|
||||
var shadow = mText.gameObject.GetComponent<Shadow>();
|
||||
if (shadow != null)
|
||||
{
|
||||
|
||||
@@ -252,8 +252,17 @@ public class DeviceView : MonoBehaviour
|
||||
logo.sprite = sprite1;
|
||||
|
||||
title.text = connectedDevice.Name;
|
||||
noDevice.text = connectedDevice.DeviceNumber.ToString();
|
||||
if (connectedDevice.Network == NetworkType.BLE)
|
||||
{
|
||||
noDevice.enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
noDevice.enabled = true;
|
||||
noDevice.text = connectedDevice.DeviceNumber.ToString();
|
||||
}
|
||||
searchState.text = "Connecting...";
|
||||
|
||||
}
|
||||
else if (connectedDevice.State == DeviceState.Connected)
|
||||
{
|
||||
|
||||
@@ -99,6 +99,17 @@ public class BigMapController : PFUIPanel
|
||||
var panel = canvas.transform.Find("Panel");
|
||||
base.SetRounded(panel, 30f);
|
||||
|
||||
|
||||
var qtcm = this.transform.Find("Map").GetComponent<QuadTreeCameraMovement>();
|
||||
UIManager.AddEvent(panel.gameObject, EventTriggerType.PointerEnter, (e) =>
|
||||
{
|
||||
qtcm.enabled = false;
|
||||
});
|
||||
UIManager.AddEvent(panel.gameObject, EventTriggerType.PointerExit, (e) =>
|
||||
{
|
||||
qtcm.enabled = true;
|
||||
});
|
||||
|
||||
content = panel.Find("Scroll View").Find("Viewport").Find("Content").gameObject;
|
||||
var input = panel.Find("InputField");
|
||||
base.SetRounded(input, 20f);
|
||||
|
||||
Reference in new issue
Block a user