void Awake() { // NetworkManager.singleton is null for some reason manager = FindObjectOfType <NetWorkController>(); // button onclicks btnQuit.onClick.SetListener(() => { Application.Quit(); }); btnLogin.onClick.SetListener(() => { manager.StartClient(); }); btnHost.onClick.SetListener(() => { manager.StartHost(); }); btnCancel.onClick.SetListener(() => { manager.StopClient(); }); btnDedicated.onClick.SetListener(() => { manager.StartServer(); }); }
/// <summary> /// Extracts PCIe Bus information from the registry, based on the NIC /// PNPDeviceID. /// </summary> private static void GetPciLocationInfo(string pnpDeviceId, ref NetWorkController nic) { Regex pciFormat = new Regex(PciFormat); Regex pciIndex = new Regex(PciIndex); string key = RegLocalMachineKey + pnpDeviceId; string location = string.Empty; try { RegistryKey regkey = Registry.LocalMachine.OpenSubKey(key, RegistryKeyPermissionCheck.ReadSubTree, System.Security.AccessControl.RegistryRights.ReadKey); if (null != regkey) { location = (string)regkey.GetValue(RegStringValue); } } catch (Exception) { nic.ValidNetworkCtrl = false; } if (!string.IsNullOrEmpty(location)) { Match pciInfo = pciFormat.Match(location); if (pciInfo.Success) { MatchCollection pciLocation = pciIndex.Matches(pciInfo.Groups["bus"].Value.ToString()); if (pciLocation.Count == 3) { nic.SetPciInfo(pciLocation[0].Value, pciLocation[1].Value, pciLocation[2].Value); } else { nic.ValidNetworkCtrl = false; } } else { nic.ValidNetworkCtrl = false; } } else { nic.ValidNetworkCtrl = false; } }
void Awake() { Top10Elapsed = 0; IsShowRanking = false; isStart = false; Screen.orientation = ScreenOrientation.Landscape; camera = Camera.main; GameObject rankingPre = Resources.Load("Ranking") as GameObject; if(rankingPre != null) { GameObject rank = GameObject.Instantiate(rankingPre) as GameObject; if(rank != null) { rank.transform.SetParent(UICanvasPanel); rank.transform.localScale = new Vector3(1f, 1f, 1f); RectTransform rt = rank.GetComponent<RectTransform>(); if(rt != null) { rt.offsetMax = new Vector2(0f, 0f); rt.offsetMin = new Vector2(979f, 230f); } else { Debug.LogError("rt null"); } rankingButton = rank.transform.GetChild(0); rankingList = rank.transform.GetChild(1); rankingList.gameObject.SetActive(false); Debug.Log("Init ranking successfully!"); } } else { Debug.LogError("Ranking.prefab null"); } //characterList = new List<Character>(); if (PawnParent == null) { PawnParent = GameObject.Find("PawnParent").transform; } if (isStart) { GetMainActor ().SetMainActor (true); } else { UICanvasPanel.gameObject.SetActive(false); } updateFreq = 10; updateCount = 0; netCon = GetComponent<NetWorkController> (); }
/// <summary> /// Get Network Controller PCIe location /// </summary> private static List <NetWorkController> GetNetworkControllers() { ManagementObjectSearcher objadapter = new ManagementObjectSearcher(PhysicalAdapterQuery); ManagementObjectCollection adapters = objadapter.Get(); if (adapters != null) { // enumerate management controllers with valid properties foreach (ManagementBaseObject adapterInstance in adapters) { NetWorkController nic = new NetWorkController(true); if (adapterInstance[WmiPropertyName.Index.ToString()] != null) { nic.Index = (uint)adapterInstance[WmiPropertyName.Index.ToString()]; } else { nic.ValidNetworkCtrl = false; } if (adapterInstance[WmiPropertyName.MACAddress.ToString()] != null) { nic.MacAddress = (string)adapterInstance[WmiPropertyName.MACAddress.ToString()]; } else { nic.ValidNetworkCtrl = false; } if (adapterInstance[WmiPropertyName.PNPDeviceID.ToString()] != null) { GetPciLocationInfo((string)adapterInstance[WmiPropertyName.PNPDeviceID.ToString()], ref nic); } else { nic.ValidNetworkCtrl = false; } if (nic.ValidNetworkCtrl) { controllers.Add(nic); } } } if (objadapter != null) { objadapter.Dispose(); } if (adapters != null) { adapters.Dispose(); } // Quick sort controllers by pcie bus, then deviceId controllers.Sort(); // Update physical Nic index based on Pcie bus and deviceId for (int i = 0; i < controllers.Count; i++) { controllers[i].PhysicalIndex = i; } return(controllers); }