使用unity开发项目,使用lua脚本.获取设备的外网ip.
local ip_ = nil;
coroutine.start(function()
local http = "http://ip.myhostadmin.net/"
local wwwip = WWW(http);
coroutine.www(wwwip);
local text = JudgeIPString(string.match(wwwip.text, "(%d+.%d+.%d+.%d+)"));
if ip_Back == false and text ~= false then
if wwwip.error ~= nil then
ip_ = nil;
end
if wwwip.isDone then
ip_ = true;
end
if ip_ == true then
ip_ = text or nil;
end
end
end)