Как подключить телефон к юнити
Перейти к содержимому

Как подключить телефон к юнити

  • автор:

Unity Remote

Unity Remote is a downloadable application that helps with Android, iOS Apple’s mobile operating system. More info
See in Glossary , and tvOS development. Unity Remote connects your target device to the Unity Editor and displays the visual output from the Editor on the target device’s screen at a reduced framerate. It also sends live inputs from the target device back to the running project in Unity. This is useful to see how an application looks and handles on the target device without creating a build.

The target device streams the following input data back to the Editor:

  • Touch and stylus input
  • Accelerometer
  • Gyroscope
  • Device camera A component which creates an image of a particular viewpoint in your scene. The output is either drawn to the screen or captured as a texture. More info
    See in Glossary streams
  • Compass
  • GPS
  • Joystick names and input.

The Unity Editor still performs the application’s actual processing on the desktop machine. This means that performance is not an accurate reflection of how the built application performs on the target device. To get a more accurate assessment of the application’s performance, make sure to occasionally build the application and test the build on the target device.

Requirements and compatibility

Unity Remote supports Android, iOS, and tvOS devices. To connect Unity Remote to an Android device, you need to have the Android SDK on your development machine. To specify the location of your Android SDK, go to Edit > Preferences (macOS: Unity > Preferences).

Note: Unity Remote replaces the iOS Remote and Android Remote applications from earlier versions of Unity. Unity no longer supports these older applications.

Set up Unity Remote

To set up Unity Remote:

  1. Install the application on the target device.
  2. Connect the target device to your computer.
  3. Connect the Unity Editor to Unity Remote.

Install Unity Remote

Download the Unity Remote application from Google Play.

Connect the target device to your computer

After you install Unity Remote on the target device, run Unity Remote then connect the target device to your computer. To do this for Android, use a USB connection.

Connect Unity Remote to the Unity Editor

With the target device connected to your computer, the Unity Editor should be able to see it. To connect Unity Remote on the target device to the Unity Editor:

  1. Open Editor settings (menu: Edit > Project Settings > Editor).
  2. In the Unity Remote section, set Device to the device you want to use.

Important: Unity doesn’t support Unity Remote on multiple connected Android devices. To resolve this, Unity automatically picks the first Android device it finds. However, you can have multiple iOS/tvOS devices and one Android device connected at the same time. All of these connected devices appear in the Device lists.

Preview an application in Unity Remote

In the Editor, click the Play button to see the application appear on the target device and in the Game View. As the application runs, Unity Remote streams input back to the Unity Editor and your scripts A piece of code that allows you to create your own Components, trigger game events, modify Component properties over time and respond to user input in any way you like. More info
See in Glossary handle the inputs as if the scripts were running on the target device itself.

Performance

When you use Unity Remote, the application actually runs in the Editor, and Unity streams the visual content to the target device. The bandwidth between the Editor and the device is limited so Unity compresses the stream for transmission. The default compression A method of storing data that reduces the amount of storage space it requires. See Texture Compression, Animation Compression, Audio Compression, Build Compression.
See in Glossary method is JPEG which is a lossy compression method that reduces the image quality.

Change the compression method

One way to improve image quality on Unity Remote is to change the compression method to PNG. PNG is a lossless compression method that uses more bandwidth but doesn’t reduce the image quality. To change the compression method to PNG:

  1. Open Editor settings (menu: Edit > Project Settings > Editor).
  2. In the Unity Remote section, set Compression to PNG.

Change the resolution

By default, when Unity streams the application to Unity Remote, it downsizes the application’s resolution. This results in a smaller image that reduces image quality but has a lower bandwidth requirement and produces better runtime performance. To preview your application at the application’s full resolution:

Open Editor settings (menu: Edit > Project Settings > Editor).

In the Unity Remote section, set Resolution to Normal.

Удаление Unity

Unity Remote – это загружаемое приложение, помогающее работать с Android, iOS мобильной операционной системой Apple. Подробнее
См. в разделе Словарь , а также в разработке для tvOS. Unity Remote подключает ваше целевое устройство к редактору Unity и отображает визуальный вывод из редактора на экране целевого устройства с уменьшенной частотой кадров. Он также отправляет живые входные данные с целевого устройства обратно в работающий проект в Unity. Это полезно, чтобы увидеть, как приложение выглядит и работает на целевом устройстве, не создавая сборку.

Целевое устройство передает следующие входные данные обратно в редактор:

  • Сенсорный ввод и ввод стилусом
  • Акселерометр
  • Гироскоп
  • Устройство камера Компонент, который создает изображение определенной точки обзора в вашей сцене. Вывод либо рисуется на экране, либо фиксируется в виде текстуры. Подробнее
    Посмотреть в потоках Словарь
  • Компас
  • GPS
  • Названия джойстиков и ввод.

Редактор Unity по-прежнему выполняет фактическую обработку приложения на настольном компьютере. Это означает, что производительность не является точным отражением работы созданного приложения на целевом устройстве. Чтобы получить более точную оценку производительности приложения, периодически собирайте приложение и тестируйте сборку на целевом устройстве.

Требования и совместимость

Unity Remote поддерживает устройства Android, iOS и tvOS. Чтобы подключить Unity Remote к устройству Android, на компьютере для разработки должен быть установлен Android SDK. Чтобы указать расположение Android SDK, перейдите в раздел Изменить > Настройки (для macOS: Unity > Настройки).

Примечание. Unity Remote заменяет приложения iOS Remote и Android Remote из более ранних версий Unity. Unity больше не поддерживает эти старые приложения.

Настройка Unity Remote

Чтобы настроить Unity Remote:

  1. Установите приложение на целевое устройство.
  2. Подключите целевое устройство к компьютеру.
  3. Подключите редактор Unity к Unity Remote.

Установите Unity Remote

Загрузите приложение Unity Remote из Google Play. .

Подключите целевое устройство к компьютеру

После установки Unity Remote на целевом устройстве запустите Unity Remote, а затем подключите целевое устройство к компьютеру. Чтобы сделать это для Android, используйте USB-подключение.

Подключить Unity Remote к редактору Unity

Когда целевое устройство подключено к вашему компьютеру, редактор Unity должен его увидеть. Чтобы подключить Unity Remote на целевом устройстве к редактору Unity:

  1. Откройте Настройки редактора (меню: Правка >Настройки проекта >Редактор ).
  2. В разделе Unity Remote установите для параметра Device устройство, которое вы хотите использовать.

Важно: Unity не поддерживает Unity Remote на нескольких подключенных устройствах Android. Чтобы решить эту проблему, Unity автоматически выбирает первое найденное устройство Android. Однако вы можете одновременно подключить несколько устройств iOS/tvOS и одно устройство Android. Все эти подключенные устройства отображаются в списках Устройства.

Предварительный просмотр приложения в Unity Remote

В редакторе нажмите кнопку «Воспроизвести», чтобы приложение появилось на целевом устройстве и в представлении игры. Во время работы приложения Unity Remote передает входные данные обратно в редактор Unity и ваши скрипты фрагмент кода, позволяющий создавать собственные Компоненты, запускать игровые события, изменять свойства Компонентов с течением времени и реагировать на действия пользователя любым удобным для вас способом. Подробнее
См. в разделе Словарь обработка входных данных, как если бы сценарии выполнялись на целевом устройстве. себя.

Производительность

При использовании Unity Remote приложение фактически запускается в редакторе, а Unity передает визуальный контент на целевое устройство. Пропускная способность между редактором и устройством ограничена, поэтому Unity сжимает поток для передачи. Используемый по умолчанию сжатие метод хранения данных, уменьшающий требуемый объем дискового пространства. См. Сжатие текстур, Сжатие анимации, Сжатие звука , Сжатие компоновки.
См. в Словарь метод — это JPEG, который представляет собой метод сжатия с потерями, уменьшающий изображение. качественный.

Изменить метод сжатия

Один из способов улучшить качество изображения в Unity Remote — изменить метод сжатия на PNG. PNG — это метод сжатия без потерь, который использует большую полосу пропускания, но не снижает качество изображения. Чтобы изменить метод сжатия на PNG:

  1. Откройте Настройки редактора (меню: Правка >Настройки проекта >Редактор ).
  2. В разделе Unity Remote установите для параметра Сжатие значение PNG.

Изменить разрешение

По умолчанию, когда Unity передает приложение в Unity Remote, разрешение приложения уменьшается. Это приводит к меньшему размеру изображения, что снижает качество изображения, но имеет более низкие требования к полосе пропускания и обеспечивает лучшую производительность во время выполнения. Для предварительного просмотра вашего приложения в полном разрешении приложения:

Откройте Настройки редактора (меню: Правка > Настройки проекта > Редактор).

В разделе Unity Remote установите для параметра Разрешение значение Нормальное.

Unity Remote 5 — Mobile Testing

Unity Remote 5 — Mobile Testing — Mobile Development — Game Dev

Unity Remote 5 — App for Mobile Testing on iOS & Android using Unity Editor & Mobile Phone with USB Connection without Building of App. It’s the only solution to quick checking of ideas.

Unity Remote is mainly used to Test Sensors that are only on Mobile Phone (gyro, accelerometer, compass, etc.). So you will see your mobile game on Phone (also in Unity Editor) & get data from Sensors.

Mobile Testing with Unity Remote: Tips & Tricks

There are some inconveniences (not bugs, it’s by design) & features:

  1. You need to hit Play — Stop — Play in Unity Editor for sensor detecting in first time.
  2. You can freeze a state of sensor by turning off the screen of mobile phone or by disabling of wire. This is convenient if you need to test the game at the moment with certain sensor values.
  3. When switching between testing via wire and without it, you need to restart Unity Editor to reset sensor data.

Gyroscope & Accelerometer

You can test data of Gyroscope & Accelerometer sensors, so you can use Unity Remote while Developing AR Apps with AR Camera Lite (docs).

Camera

You can’t test Camera Stream with WebCamTexture from Mobile Phone (docs are wrong), so in Unity Editor & on Mobile Phone you will see Camera Stream from laptop. If you know the magic of how to make it work, please share it in comments.

Unity Remote 5 Not Working

To solve your problems Check Tutorials:

Unity Issue Tracker

Your Votes are Needed here:

Building

The next step after Testing with Unity Remote is Building. Building is the only way when you can get real experience about Mobile App because the behavior of Real Build may be different.

Mobile Building Environment for Unity Testing

The video below shows my building testing environment to cover iOS and Android devices.

My working operating system is macOS, because it’s the only way to test Unity iOS apps comfortably. Windows-machines can also be used for testing with iOS Project Builder for Windows.

AR Remote Tool

AR Foundation

AR Foundation (ARKit, ARCore) Editor Remote — AR Remote Tool allowing you test AR App without building right in Unity Editor.

Getting Unity Remote for Android to work on Windows

Do you find it cumbersome to test your game using an actual mobile device? Simulate it with the Unity Device Simulator instead! We’ve got a guide to show you how to set it up.

If you’re developing a game for Android on Unity, Unity Remote is an irreplaceable tool that allows you to quickly test your game on your Android device using Unity’s built-in Play-in-Editor feature. Unfortunately, it can also be pretty difficult to get Unity Remote to work, since it requires some very specific configurations on both your Android device and your computer.

Available solutions online are often incomplete, inaccurate, or outdated (Unity Remote was released more than 4 years ago, and the Android development scene is very different from how it was then), so you often have to piece solutions from multiple sources to get one that works. After grappling for hours to get Unity Remote working on multiple computers (and a lot of frustration), I’ve decided to write a set of articles to save you the same frustration. Hopefully, this will save you from 9000 Google searches and a damaged keyboard.

For ease of access, this article has been separated into multiple sections and sub-sections, which are listed below. If you’ve already gone through some steps to set up Unity Remote, and don’t want to read through the whole article, you can jump straight to the Connecting and basic troubleshooting section, or to our other article for more advanced troubleshooting tricks.

1. Preparing your device

For Unity Remote to work, you need to make sure your Android device has:

a. Enabling USB debugging

To enable USB debugging on your Android device, you first need to un-hide the Developer Options tab in your device settings by finding and tapping the Build number sub-tab 7 times.

The location Build number is slightly different for every Android device, so you need to do a bit of searching. For most devices, it should be found somewhere inside Settings > About phone or Settings > About device.

Tap build number 7 times

Doing this makes you feel smart, doesn’t it?

Once that is done, find your way into the newly-revealed Developer Options tab under your device settings, and enable USB debugging.

Developer Options in Android

Congratulations, you are now a hacker.

Enabling USB debugging in Android

But don’t get too excited. Lots more to do.

b. Installing Unity Remote 5

Remember to also install the Unity Remote 5 app onto your Android device. Once you are done with that, you can move on to configuring your computer.

Article continues after the advertisement:

2. Preparing your computer

For Unity Remote to work with your computer (and Unity installation), you’ll need to make sure that:

    (with Unity-native Android SDK and NDK Tools, and OpenJDK)

a. Installing Android Build Support for Unity

Android Build Support is a Unity Editor extension that adds a suite of features for designing games on Android devices. To add it to an existing Unity installation, open Unity Hub and head to the Installs tab. Click on the dropdown of the Unity version you want to install Android Build Support for, then select Add Modules.

If your version of Unity was not installed with Unity Hub, you’ll want to uninstall it and re-install it using Unity Hub. You won’t be able to add modules onto independent installations of Unity, as Unity has phased that feature out with the release of Unity Hub.

Check the Android Build Support, then click on the dropdown beside it to make sure that Unity’s native Android SDK and NDK Tools, as well as OpenJDK, are checked too. Once that is done, click on Next and agree to the terms and conditions pop-up to start installing these extensions.

Android SDK and NDK Tools and OpenJDK are only available to Unity 2019.1 and above. If you are using an older version of Unity, you will have to download these packages yourself and link them to Unity under Edit > Preferences > External Tools. Consider upgrading, as Unity is very specific with the versions of the SDK and JDK its Android Build Support module can work with.

Android Build Support modules for Unity Remote

If Android Build Support is ticked in a grey checkbox, that means it’s already installed.

b. Ensuring the JDK, SDK and NDK are linked

Once installation for Android Build Support is complete, open your project in Unity (use the same version you’ve installed Android Build Support for). Then, go to Edit > Preferences and click on the External Tools tab.

Under the Android section of the tab, make sure that you have the following checkboxes marked (shown in the image below):

Unity

If you are missing this whole section, then you haven’t installed Android Build Support yet.

Avoid using your own SDK, NDK or JDK installations. If there are incompatibility issues, it will stop Unity Remote from working.

c. Enabling Unity Remote in the Editor

Finally, head to the window at Edit > Project Settings, and select the Editor tab (refer to the image below).

In the tab, set the Device field to Any Android Device. This will enable the Unity Editor to interface with the Unity Remote app on your phone.

Setting the Unity Remote device

If nothing goes wrong, Unity Remote should work once you start Play-in-Editor on your desktop.

Your Unity Editor is now ready for Unity Remote (hopefully).

Keep your fingers crossed as you scroll down to the next section.

Looking for the section on installing Google USB Driver? We’ve actually found that it was not necessary for some computers to get Unity Remote working, so we’ve moved it to our other article. Here’s a direct link.

Article continues after the advertisement:

3. Connecting and basic troubleshooting

a. Allow USB debugging

To connect Unity Remote to your Editor, fire up the Unity Remote, and connect it to your computer using a USB cable. If you get an Allow USB debugging prompt on your Android device, consider yourself extremely lucky, because that means Unity has detected it.

Android USB Debugging prompt

Whenever I got this prompt, that meant Unity Remote was moments away from working on my computer.

Press OK to allow USB debugging. Then, enter Play Mode in the Editor. You should get some lag the first time you do it (on your desktop, Android device, or both), but Unity Remote should eventually mirror your Game screen.

If that happens, you’re done. You can close this article now.

Sometimes, it takes entering Play Mode a couple of times before Unity Remote starts working. If you have the USB debugging prompt, it is very likely that Unity will start working after a few tries.

Otherwise, if you’ve got…

b. No USB debugging prompt

That means that your Android device is unable to connect to the Unity Editor. There are a plethora of reasons that can be the cause of this, and a whole gamut of methods that can potentially fix this. Before we try the more complex methods, however, you’d want to:

  1. Double-check that you have set Unity Editor to use Any Android device. Refer to this section above if you don’t know what I’m talking about.
  2. Make sure you are in the Unity Remote app on your Android device. It only works if the app is on. Yes, it’s an obvious point — I’m just making sure.
  3. Try a different USB wire and / or a different USB port. Some USB wires and ports are for charging only, and aren’t able to transmit data.
  4. Disconnect and re-connect your USB wire a couple of times. Your computer might not have detected your Android device the first (few) time.

If the above didn’t work, then I’ll recommend you head over to our other article titled More tricks to get Unity Remote for Android working on Windows. That whole article (mostly) is about the various things you can install or tweak in your Editor and your Android device to get the USB debugging prompt to register.

Alternatively, you can also try the following methods. People have reported that some of these worked for them. It has never worked for me, however:

  1. Close and re-open Unity on your computer. Sometimes this does the trick.
  2. Restart Unity Remote on your Android device. Other times, this does the trick.
  3. Restart your computer and / or your Android device. If you’re really unfortunate, this is what will do the trick.
  4. Do (5), (6) and (7) in random order for several times. Sometimes, the order in which the apps are opened can affect whether the connection is detected.
  5. Restart both the Unity Editor (on the computer) and Unity Remote (on your device), then plug in your device with both applications on. Some computers are very particular about this sequence.
  6. Try using a different device, then restart your original device and try it again. If it works on the other device, it means you are doing something right!
  7. Try running Unity Remote on a different Unity project, then go back to your original one. Weird, but this has worked for people too.

Another helpful note: If you notice that when your device is connected but not detecting, or it is only charging but not connecting (i.e. you can’t access the files on your device), check out this article from another site.

4. Afterword

I hope that this article has been helpful to you in some way. If not, you can head over to our other article for more things you can try to get Unity Remote working, or read the comments section to see what has worked for other people.

Lastly, if you:

  1. Find any errors in this article, or;
  2. Find a method that gets Unity Remote to work, that is not listed in this article (or the other one);

Please leave a comment with the details! This article will be constantly updated with new findings, and you’ll be doing a public service to everyone else who is or will be going through the same battle of getting Unity Remote to work.

Article continues after the advertisement:

There are 24 comments:

Thanks for the guide! The only additional step I needed (on Unity 2019.4.8f1) was to set the Game View’s aspect ratio setting to “Remote (Not Connected)”. After setting that and hitting Play, the remote connection worked great, and continued to work fine even if I changed the aspect ratio to something else.

Project settings – Editor – Device = Any android device. Worked for me. 11/04/2022.

Thank you for this tutorial, works as of 2/2/2022

thanks for the hints !
worked after
-changing unity settings to target android in
–target platform
–editor-unity remote device
–jdk sdk ndk update
-android studio installation

Hey Terence, thank you so so so much for this article. I hadn’t looked in the one with more tricks, so this might not be necessary, but I got mine to work by going into unity hub and changing the target platform to android. Hope this is new info that helps! Again, thank you so so so so so so much I do not know what I could have done without you

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *