About the method of connecting Unity to Unity Remote 5 on the MuMu simulator

In the process of using Unity to develop Android, you can use the Unity Remote app to connect to the real machine to test performance and other tasks in the real environment. This time it is a small pit caused by other problems, recorded for future reference. Follow-up inquiries.

This time it was due to a project I encountered during the self-study process. Although it was developed for Android, the problem was that the game interface of Unity could not perform click operations within the game. After checking, it was found that its internal code was used to obtain click information. This Input.touchesinterface It seems that it is only valid on the mobile terminal, so the game cannot be controlled in the Game interface that comes with Unity. Although you can also change the code yourself to solve the problem, but I also thought that I have never connected to Unity using the simulator before, so I will try it here.

Step 1: Install Unity Remote 5 on the simulator

Step 2: Turn on the developer mode of the emulator

Step 3: Set up Unity

Insert image description here
Insert image description here
Step 4: Connect to the emulator via adb command

And here is the pit of this time, and it took nearly half an afternoon to check it before I suddenly realized it.

When going to the fourth step, usually you can use a command to connect to the Android device smoothly.

adb connect 127.0.0.1:7555

Here 7555is MuMu模拟器the port number.
The port numbers for some other emulators are as follows:

夜神模拟器:62001
MuMu模拟器:7555
天天模拟器:6555

Of course, if you are connecting to a real machine, you only need to plug in a cable, but here you are connecting to an emulator, so some additional operations are required.

If it is a real phone, plug it in, open Unity Remote 5 and click Unity's Play, you can see the screen in Unity projected on the phone screen. However, after following the above steps, there is no response in the simulator.

After that, I searched again and again, but to no avail, and there was no explanation.

Later, after reading an article, I had an idea that it might be an adb problem, so after testing, it turned out to be the case.

The reason is that since the path of adb has been configured in my computer, the adb used in cmd is under Android Studio. The fully downloaded Unity comes with an adb. For example, the adb location of the 2019.4.40 version I use is:
2019.4.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools
After entering the directory through cmd, use this adb to connect to the simulator, so that you can connect to the simulator normally with Unity. Unity Remote 5 in the simulator.

Guess you like

Origin blog.csdn.net/EverNess010/article/details/132765974