Unity Foundation Development----Unity gets information such as the MAC address of the Pc,ios system

Source: Internet
Author: User

In software development, MAC addresses can be used as a unique indication of the device, and we can also get it through unity, which can be tested by Pc,ios but not available to Android.

The code is as follows:

usingUnityengine;usingSystem.Collections;usingSystem.Net.NetworkInformation; Public classnetworkinfo:monobehaviour{voidStart () {Debug.Log (getmacaddress ()); }     Public Static stringgetmacaddress () {stringPhysicaladdress =""; Networkinterface[] Nice=networkinterface.getallnetworkinterfaces (); foreach(NetworkInterface AdaperinchNice ) {Debug.Log (adaper).            Description); if(Adaper. Description = ="En0") {physicaladdress=Adaper. Getphysicaladdress ().                ToString ();  Break; }            Else{physicaladdress=Adaper. Getphysicaladdress ().                ToString (); if(Physicaladdress! ="")                {                     Break;            }; }        }        returnphysicaladdress; }
voidOngui () {GUI. Label (NewRect (0,0, $, -),"mac="+getmacaddress ()); }}

Additional notes:

usingUnityengine;usingSystem.Collections;usingSystem.Net.NetworkInformation; Public classTest:monobehaviour {voidStart () {networkinterface[] NIS=networkinterface.getallnetworkinterfaces (); foreach(NetworkInterface niinchNIS) {Debug.Log ("Name ="+ni.            Name); Debug.Log ("Des ="+ni.            Description); Debug.Log ("Type ="+ni.NetworkInterfaceType.ToString ()); Debug.Log ("MAC address ="+ni. Getphysicaladdress ().            ToString ()); Debug.Log ("------------------------------------------------"); }    }}

Unity Foundation Development----Unity gets information such as the MAC address of the Pc,ios system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.