using AdamSync; using System.Collections; using System.Collections.Generic; using UnityEngine; public class DeviceManager : MonoSingleton { /// /// 所有设备 /// public List devices = new List(); // Start is called before the first frame update void Start() { SyncCreateRoom.send2roomRequset += GetSend2roomMsg; } /// /// 发送消息 /// public Queue send2roomStr = new Queue(); private void Update() { if (send2roomStr.Count > 0) { _ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", send2roomStr.Dequeue())); } } public void AddDevice(EquipmentCommon d) { if (!devices.Contains(d)) { devices.Add(d); } } public void GetSend2roomMsg(string data) { data = data.Replace("send2room", ""); Debug.LogError("设备..:" + data); string[] info = data.Split(','); if (info.Length < 2) return; EquipmentCommon equipmentCommon = devices.Find(x => x.deviceID == info[1]); if (equipmentCommon) { equipmentCommon.ReceivingPositionAngle(info); } } public void OnDisalbe() { SyncCreateRoom.send2roomRequset -= GetSend2roomMsg; } }