Hey guys! I found the solution. This code works on MacOS and on iOS. I haven’t tested on Android.
// Returns the 1st valid Mac Address
function GetMacAddress(){
var macAdress = "";
var nics : NetworkInterface[] = NetworkInterface.GetAllNetworkInterfaces();
var i = 0;
for (var adapter: NetworkInterface in nics){
var address: PhysicalAddress = adapter.GetPhysicalAddress();
if(address.ToString() != ""){
macAdress = address.ToString();
return macAdress;
}
}
return 0;
}
Hello sorry for keep wth this thread, but Im still unable to access the mac of my android device from unity.
I think your answer is the most aproximate to the solution but I still can’t access the mac of the device,
¿Please can someone help me?
I dont know exactly how people feel about resurrecting dead threads but I would recommend creating your own one thread as this usually annoys people on forums.
@APGame Hi, I would like to point out that I was using @master2001 solution, which worked fine on my testing device (Android 4.0), but after testing in others devices and some research I found this code it is not working anymore on Android 6.0+. Unfortunately, I didn´t find another way to retrieve the Mac Address, but in my case I needed a unique identifier for each device, so the solution I found (although it is not the best one, it is the most reliable at the moment) is quite simple, use https://docs.unity3d.com/ScriptReference/SystemInfo-deviceUniqueIdentifier.html instead. I took the solution from here: How to find mac address in ios and android? - Questions & Answers - Unity Discussions. Hope this helps you or somebody else.
I have search this solution for a long time, there is no way that i can find to sovle this problem by Using Unity API, the way i take is building plugins to Android/IOS.
if anyone know the solution to sovle this issue, I am glad to hear from you~~