今天真是又学了一招,使用mac地址给项目加密,防止被盗用信息,
bool isOpen = false; private void Start() { NetworkInterface[] nis = NetworkInterface.GetAllNetworkInterfaces(); foreach (NetworkInterface ni in nis) { //如果网络接口的类型是以太网,因为还有其他的接口类型。 if (ni.NetworkInterfaceType.ToString()== "Ethernet") { Debug.Log("Name = " + ni.Name); Debug.Log("Des = " + ni.Description); Debug.Log("Type = " + ni.NetworkInterfaceType.ToString()); Debug.Log("Mac = " + ni.GetPhysicalAddress().ToString()); //可以得到我们运行项目的电脑的物理地址 Debug.Log("------------------------------------"); _MacAddress = ni.GetPhysicalAddress().ToString(); //获取我们电脑上的mac地址 } } } private void Update() { //如果我们现在电脑上的mac地址等于我们需要加密的电脑的地址,那么就让项目正常运行否则,立即退出 if (!_MacAddress.Contains("14DDA952E562")) { isOpen = true; } if (isOpen) { Quit(); } } /// <summary> /// 退出程序 /// </summary> public void Quit() { #if UNITY_EDITOR UnityEditor.EditorApplication.isPlaying = false; #else Application.Quit(); #endif } bool isOpen = fals