using System.Collections; using System.Collections.Generic; using Kill.Managers; using UnityEngine; using UnityEngine.UI; namespace Kill.UI.Pages { public class HomePageDevicePage : MonoBehaviour { public GameObject devicePrefab; public GameObject typePrefab; private string[] typeKey = new string[] { "100148", "100149" }; private string[] typeStr=new string[2]; public Transform deviceParent; private List deviceList; private List typeList; public DeviceInfo lastSelectedDevice; public DeviceInfo selectedDevice; public Text selectedDeviceName; public void InitDeviceList(List ownedDevices, List sharedDevices, DeviceInfo selectedDevice) { selectedDeviceName.text=selectedDevice.device_name; typeStr[0]=LanguageManager.Instance.GetLanguage(typeKey[0]); typeStr[1]=LanguageManager.Instance.GetLanguage(typeKey[1]); lastSelectedDevice = selectedDevice; this.selectedDevice = selectedDevice; devicePrefab.SetActive(false); typePrefab.SetActive(false); if (deviceList != null && deviceList.Count > 0) { foreach (var item in deviceList) { Destroy(item); } deviceList.Clear(); } if (typeList != null && typeList.Count > 0) { foreach (var item in typeList) { Destroy(item); } typeList.Clear(); } deviceList = new List(); typeList=new List(); if(ownedDevices!=null&&ownedDevices.Count>0) { Text type=Instantiate(typePrefab, deviceParent).GetComponent(); type.text=typeStr[0].Replace("{0}",ownedDevices.Count.ToString()); type.gameObject.SetActive(true); typeList.Add(type.gameObject); } foreach (var device in ownedDevices) { if (string.IsNullOrEmpty(device.ble_mac)) { device.ble_mac=device.device_sn; } var deviceItem = Instantiate(devicePrefab, deviceParent); deviceItem.SetActive(true); deviceItem.GetComponent().InitDeviceItem(device); deviceList.Add(deviceItem); deviceItem.gameObject.SetActive(true); deviceItem.GetComponent