using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using SmartBowLib; using SmartBowLib.lebo; using Newtonsoft.Json.Linq; /* * 投屏功能的用户操作界面 */ public class ScreenProjectionView : MonoBehaviour, MenuBackInterface { //stage1 public Transform uiDeviceListContent; public GameObject uiDeviceListItem; public Button btnResolution; //stage2 public Text textDeviceLabel; public Button btnStop; private int _stageNum = 1; public static ScreenProjectionView ins; void Awake() { ins = this; DontDestroyOnLoad(this); uiDeviceListItem.SetActive(false); } void Start() { InitBtn_SetResolution(); btnStop.onClick.AddListener(OnClick_BtnStop); MsgReceiver.ins.onMessage += onMessage; #if UNITY_ANDROID && !UNITY_EDITOR ScreenProjection.Init(); if (!ScreenProjection.ins) _needReinitSDK = true; #endif } void OnDestroy() { if (ins == this) ins = null; MsgReceiver.ins.onMessage -= onMessage; } void OnEnable() { PersistenHandler.ins?.menuBackCtr.views.Add(this); } void OnDisable() { PersistenHandler.ins?.menuBackCtr.views.Remove(this); } public bool OnMenuBack() { LogicBtnBack(); return true; } void onMessage(string tag, string msg) { if (tag == "lebo.onBrowse") OnBrowse(JArray.Parse(msg)); } class LeboDeviceServiceInfo { public string uid; public string name; public GameObject o; public bool valid; } Dictionary deviceMap = new Dictionary(); void OnBrowse(JArray list) { foreach (var item in deviceMap) { item.Value.valid = false; } foreach (var jo in list) { string uid = jo.Value("uid"); string name = jo.Value("name"); if (deviceMap.ContainsKey(uid)) { deviceMap[uid].valid = true; continue; } var info = new LeboDeviceServiceInfo(); info.uid = uid; info.name = name; GameObject o = Instantiate(uiDeviceListItem, uiDeviceListContent); o.GetComponentInChildren().text = name; o.GetComponent