如何从 android 模拟器访问统一游戏的本地主机

How to reach the localhost of a unity game from android emulator

我正在使用 Unity3d 开发游戏,但遇到了问题。用 C# 编写的游戏有一个使用 PHP (XAMMP)..

链接的数据库

但问题是:我尝试 post 我的 IP 地址而不是 C# 脚本中的本地主机,但我仍然无法连接数据库,

我都用过:"http:MY_PC_IP:8080/insertuser.php"; 和:"http:MY_PC_IP/insertuser.php"; 我正在使用 Nox 作为模拟器..

使用内部 IP 地址10.0.2.2

您需要使用以下命令:

adb reverse tcp:8080 tcp:8080

而不是使用 ip 地址使用 localhost