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

Unity Remote

Unity Remote is a downloadable app designed to help with Android, iOS and tvOS development. The app connects with Unity while you are running your project in Play Mode from the Unity Editor. The visual output from the Editor is sent to the device’s screen, and the live inputs are sent back to the running project in Unity. This allows you to get a good impression of how your game really looks and handles on the target device, without the hassle of a full build for each test.

Note: For Unity Remote to work, you need to have the Android SDK on your development machine.

Unity Remote replaces the separate iOS and Android Remote apps used with earlier versions. Those older Remote apps are no longer supported.

Older versions of Unity Remote are still available for use in Legacy projects; see Legacy Unity Remote documentation for more information on these versions.

Device and Feature Support

Unity Remote currently supports Android devices (on Windows and OS X via a USB connection) and iOS devices (iPhone, iPad, iPod touch and Apple TV, through USB on OS X and Windows with iTunes).

The Game View of the running Unity project is duplicated on the device screen, but at a reduced framerate. The following input data from the device is also streamed back to the Editor:

Obtaining and Using Unity Remote

You can download Unity Remote for free in the form of a Unity project that you build yourself, or as a pre-built app from the device’s app store:

Once you’ve downloaded the app, install and run it on your device and connect the device to your computer using a USB cable.

To enable Unity to work with your device, open the Editor settings in Unity (menu: Edit > Project Settings, then select the Editor category) and select the device to use from the Unity Remote section:

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

Note: To specify the location of your Android SDK, go to Edit > Preferences (Windows) or Unity > Preferences (Mac).

Click the Play button in the Editor to see your game appear on the device and in the Unity game window as Unity connects to the Remote app. While the game plays, input from the device (accelerometer, etc.) is sent to your scripts as if they were running on the device itself.

Решение проблем

I have more than one device plugged in, but only one of them works with Unity

Unity Remote doesn’t support multiple connected Android devices, and to resolve this, it automatically picks the first device it finds. However, it is fine to have multiple iOS/tvOS devices and one Android device connected at the same time, since you can select which one to use from the Editor settings (menu: Edit > Project Settings, then select the Editor category).

I’m getting really poor graphics quality when running my game in Unity Remote

When you use Unity Remote the game actually runs in the Editor, while its visual content is streamed to the target device. Since the bandwidth between the Editor and the device is limited, the stream must be compressed heavily for transmission. This compression inevitably reduces the image quality.

In the Unity Remote section of the Editor window (menu: Edit > Project Settings, then select the Editor category) you can switch the compression method between JPEG and PNG. PNG compression is “lossless” (so the image quality doesn’t degrade) but uses more bandwidth than JPEG. A downsized image has lower bandwidth requirements than one at full resolution. By changing these settings, you can trade image accuracy off against framerate as necessary. When using a lower resolution, be aware that Unity Remote downsizes images for better performance.

Bear in mind that Unity Remote is only really intended to give a quick approximate check of how your game will look and feel when running on the device. Make sure that you occasionally do a full build and test the “real” app.

Источник

Unity Remote 4

Unity Remote (currently at version 4), is a downloadable app designed to help with Android or iOS development. The app connects with Unity while you are running your project in Play mode from the editor. The visual output from the editor is sent to the device’s screen and the live inputs are sent back to the running project in Unity. This allows you to get a good impression of how your game really looks and handles on the target device without the nuisance of a full build for each test.

With version 4, Unity Remote has been completely rewritten and replaces the separate iOS and Android Remote apps used with earlier versions.

Device and Feature Support

Unity Remote currently supports Android devices (on Windows and OSX via a USB connection) and iOS devices (iPhone, iPad and iPod touch, through USB and only on OSX)

The Game view of the running Unity project is duplicated on the device screen but at a reduced framerate. The following input data from the device is also streamed back to the editor:

Note that the Remote app simply shows the visual output on the device and takes input from it. The game’s actual processing is still done by the Unity editor on the desktop machine and so its performance is not a perfect reflection of the built app.

Obtaining and Using Unity Remote

Unity Remote can be downloaded for free in the form of a Unity project that you build yourself or as a pre-built app from the device’s app store:

Having downloaded the app, you should install and run it on your device and also connect the device to your computer using a USB cable.

To enable Unity to work with your device, you should open the Editor Settings in Unity (menu: Edit > Project Settings > Editor) and select the device to use from the Unity Remote section:

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

If you now click the Play button in the editor, you should see your game appear on the device as well as the Unity game window as Unity connects to the Remote app. While the game plays, input from the device (accelerometer, etc) will be sent to your scripts as if they were running on the device itself.

Решение проблем

I have more than one device plugged in but only one of them works with Unity

Currently Unity Remote doesn’t support multiple connected devices of the same kind (ie, two iPhones or two Androids) and to resolve this, it will automatically pick the first device it finds. However, it is fine to have one iOS and one Android device connected at the same time since you can select which one to use from the Editor Settings mentioned above (menu: Edit > Project Settings > Editor).

I’m getting really poor graphics quality when running my game in Unity Remote

When you use Unity Remote, the game actually runs in the Unity editor while its visual content is streamed to the target device. Since the bandwidth between editor and device is limited, the stream must be compressed heavily for transmission and this compression inevitably reduces the image quality.

In the Unity Remote section of the Editor settings (menu: Edit > Project Settings > Editor), you can switch the compression method between JPEG and PNG and also optionally downsize the resolution of the screen image. PNG compression is “lossless” (ie, image quality doesn’t degrade) but uses more bandwidth than JPEG. A downsized image has lower bandwidth requirements than one at full resolution. By changing these settings, you can trade image accuracy off against framerate as necessary.

However, you should bear in mind that Unity Remote is only really intended to give a quick approximate check of how your game will look and feel when running on the device. You should make sure that you occasionally do a full build and test the “real” app.

The editor doesn’t connect to the iOS device on OSX

To establish the connection to the iOS device through USB, Unity uses a 3rd party utility (iproxy) which is known to misbehave occasionally. You can try the following to fix the problem:

In most cases reconnecting or restarting the iOS device is enough to restore the connection.

Источник

Эмулятор андроид для Unity Build and run

Есть несколько эмуляторов, которые успешно обрабатывают apk Unity. На все них apk надо сохранить и вручную загружать. Но не получилось найти не один, который работает по команде Build and Run, как просто подключенное android устройство.

Есть ли что то подобное? У nox app player есть интеграция с Android Studio, но с юнити при тех же настройках не работает.

Поделитесь опытом, возможно ли в один клик запускать через эмулятор приложения прям из Unity.

1 ответ 1

Для бИлда в Юнити и одновременного теста на андройде есть такая штука как Unity Remote 4.

Обычно на андройде скачивается это приложение (через google play к примеру), и также в настройках Debugging надо поставить галочку Аndroid Debugging (enable the Android Debug bridge «adb» intefrace).

Надо не забыть подключить телефон к компьютеру (или на чем идет разработка).

При запуске приложения можно будет видеть следующую картинку:

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

В Unity надо переключиться на платформу Android. А также в настройках

Edit → Project Settings → Editor в пункте Unity Remote → Device выбрать Any Android Device

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

Если телефона нет, то данная фишка может прокатить только с эмулятором андройда, установленным через AVD Manager.exe Причем настройка CPU/ABI обязательно должна быть ARM armeabi. При значении Intel x86 работать не будет.

Примерные настройки для AVD:

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

После установки эмулятора надо установить Unity Remote 4 из apk в эмулятор используя команду: adb.exe install adb.exe install path/to/apk (Windows) или adb install path/to/apk (Linux/Mac).

Источник

Mobile device input

On mobile devices, the Input class offers access to touchscreen, accelerometer and geographical/location input.

Доступ к клавиатуре на мобильных устройствах обеспечивается через iOS keyboard.

Multi-touch screen

The iPhone, iPad and iPod Touch devices are capable of tracking up to five fingers touching the screen simultaneously. You can retrieve the status of each finger touching the screen during the last frame by accessing the Input.touches property array.

Android устройства не имеют определенного лимита на количество нажатий, которое можно отслеживать. Он колеблется от устройства к устройству и может варьироваться от одного-двух нажатий на старых устройствах, до пяти нажатий на некоторых новых.

Каждое нажатие пальцем представлено в структуре данных Input.Touch:

Property:Description:
fingerIdThe unique index for a touch.
positionThe screen position of the touch.
deltaPositionThe screen position change since the last frame.
deltaTimeAmount of time that has passed since the last state change.
tapCountThe iPhone/iPad screen is able to distinguish quick finger taps by the user. This counter will let you know how many times the user has tapped the screen without moving a finger to the sides. Android devices do not count number of taps, this field is always 1.
phaseDescribes the state of the touch, which can help you determine whether the user has just started to touch screen, just moved their finger or just lifted their finger.
BeganA finger just touched the screen.
MovedA finger moved on the screen.
StationaryA finger is touching the screen but hasn’t moved since the last frame.
EndedA finger was lifted from the screen. This is the final phase of a touch.
CanceledThe system cancelled tracking for the touch, as when (for example) the user puts the device to their face or more than five touches happened simultaneously. This is the final phase of a touch.

Here’s an example script that shoots a ray whenever the user taps on the screen:

Mouse simulation

On top of native touch support Unity iOS/Android provides a mouse simulation. You can use mouse functionality from the standard Input class. Note that iOS/Android devices are designed to support multiple finger touch. Using the mouse functionality will support just a single finger touch. Also, finger touch on mobile devices can move from one area to another with no movement between them. Mouse simulation on mobile devices will provide movement, so is very different compared to touch input. The recommendation is to use the mouse simulation during early development but to use touch input as soon as possible.

Акселерометр

As the mobile device moves, a built-in accelerometer reports linear acceleration changes along the three primary axes in three-dimensional space. Acceleration along each axis is reported directly by the hardware as G-force values. A value of 1.0 represents a load of about +1g along a given axis while a value of –1.0 represents –1g. If you hold the device upright (with the home button at the bottom) in front of you, the X axis is positive along the right, the Y axis is positive directly up, and the Z axis is positive pointing toward you.

Вы можете получить значение акселерометра, путем доступа к свойству Input.acceleration.

Приведенный ниже пример скрипта позволяет двигать объект, используя акселерометр:

Фильтр низких частот

Показания акселерометра могут быть отрывистыми и с шумом. Применив низкочастотную фильтрацию на сигнал, вы сгладите его и избавитесь от высокочастотного шума.

Приведенный ниже скрипт демонстрирует, как применить низкочастотную фильтрацию на показания акселерометра:

Я хочу получить как можно более точные показания акселерометра. Что я должен делать?

Вы можете получить доступ ко всем замерам, выполненным акселерометром в текущем кадре. Следующий код иллюстрирует простое среднее всех событий акселерометра, которые были собраны в течение последнего кадра:

Источник

Настройка Android SDK

Прежде чем вы сможете запустить написанный код на Android-устройстве, нужно выполнить несколько простых действий. Это относится как к работе с Unity, так и к созданию приложений с нуля.

1. Скачать Android SDK

Зайдите на страницу Android Developer SDK. Скачайте архив с последней версией Android SDK и распакуйте его.

2. Установить Android SDK

Следуйте инструкциям на странице Installing the SDK (причём, вы можете свободно пропустить опциональные части, относящиеся к Eclipse). В шаге 4 руководства Installing the SDK убедитесь, что добавили как минимум одну Android platform (Android платформу) с уровнем API равным или выше 9 (платформа 2.3 или выше), Platform Tools и USB drivers (USB драйверы), если вы используете Windows.

3. Удостовериться, что система определяет ваше устройство

Это может быть не так просто, особенно на Windows системах, в которых драйвера часто бывают источником проблем. Также, с вашим устройством может идти дополнительная информация или особые драйверы от производителя.

Для Windows: если Andoid устройство автоматически определяется системой, вам все равно придётся обновить драйверы на те, который поставляются с Android SDK. Это делается через диспетчер устройств Windows. —>Если устройство не определяется автоматически, используйте драйверы из Android SDK или особые драйверы, предоставленные производителем. —>Дополнительную информацию можно найти здесь: USB Drivers for Windows

Для Mac: если вы разрабатываете на OSX, тогда обычно не требуется никаких дополнительных драйверов.

Если вы не уверены, что ваше устройство корректно установилось в системе, пожалуйста, прочтите страницу Решение проблем при разработке под Android для дополнительной информации.

4. Добавить путь до Android SDK в Unity

При первой сборке проекта под Android (или если Unity не сможет обнаружить SDK), вас попросят указать местоположение папки, в которую вы установили Android SDK (вы должны выделить корневую папку установленного SDK). Путь до Android SDK также можно изменить в редакторе, выбрав в меню Unity > Preferences и перейдя в раздел External Tools окна настроек.

Источник

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

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