Не работает отладка по usb unity

unixforum.org

Форум для пользователей UNIX-подобных систем

  • Темы без ответов
  • Активные темы
  • Поиск
  • Статус форума

[РЕШЕНО] Unity Remote 5

Модератор: /dev/random

[РЕШЕНО] Unity Remote 5

Сообщение devilr » 15.08.2019 00:07

На компьютере стоит Android Studio. С помощью неё удаётся создавать и отлаживать программы на Android. Т.е. вроде как «отладка через USB» работает. Решил попробовать Unity.
1) Скачал официальный Unity Hub.
2) В нём установил последнюю версию Unity. Создал приложение — всё работает, отладка есть, даже apk удалось получить и установить.
3) Узнал, что существует некое приложение под названием Unity Remote 5 (вроде как официальное, если верить в Google Play)
4) Установил. и получить картинку в нём не получается. В гугле совет один и тот же — включите отладку по USB, в настройках редактора установите «Any Android device» и нажмите кнопку Play. и ничего не происходит. В «adb devices» телефон виден.

У кого нибудь удалось заставить работать?
P.S. Если ошибся разделом, то прошу переместить тему туда, где она более уместна

Методом научного тыка выяснено: если перед подключением телефона вызвать killall -9 adb, потом подключить телефон, а только потом запустить unity — всё работает.

Источник

По какой причине может не работать Unity Remote?

В unity указаны пути к sdk/jdk/ndk.
Есть установленная Android Studio с установленными Google Play Licensing Library, Google Play services и Google USB driver
В Project Settings->Editor->Device указано «Any Android Device»
На телефоне включил режим разработчика и включил отладку по usb.
Запускаю Unity Remote, включаю игру в редакторе и ничего не происходит. Пробовал в режиме зарядке и в режиме передачи файлов. Ничего не меняется.

Имеет ли значение директория студии, sdk/jdk/ndk?

Телефон — Xiaomi Redmi Note 5.

  • Вопрос задан более двух лет назад
  • 1881 просмотр

Галочки Developer Build не было. Установил. На телефоне вылезло уведомление с подтверждением. Подтвердил. И все равно не работает.

«тот же профаилер с телефона виден,может подключится??» с таким еще не сталкивался. Где это посмотреть?

про профаилер — не знаете если , то игнорируйте. это было просто убедится, что телефон видит комп. что онив одной сети и тд.

убедитесь что у вас юнити современной версии, что то из 5.6 и новее.
и что само приложение у вас на телефоне не старое а под 5 и более новые версии
https://play.google.com/store/apps/details?id=com.

убедитесь что у вас не несколько деваисов подключено, в доке описана настроика.

а вообще похоже на прикол прошивки именно китайца. иначе в В Project Settings->Editor->Device был бы пункт именно с деваисом вашим.

если есть возможность попробуйте установить Unity Remote на другой телефон

Источник

Как настроить Unity Remote для Huawei Honor?

Устройство: Honor 8x.

Бытует мнение, что в Интернете нет смысла спрашивать. Если хочешь получить ответ на вопрос, формулируй его как гайд, и тогда придёт эксперт, разнесёт твой гайд и тут же напишет, как делать правильно. А сам вопрос все проигнорят.

Но я попробую: хочу запускать отладку в движке и тут же играть с телефона, но не выходит. Помогите.

Что пробовал делать:

  • Поставил на телефон (Honor 8x) Unity Remote 5.
  • Соединил с ноутбуком по USB-кабелю.
  • В панели разработчика на телефоне включал отладку по USB (галочка слетает, как только закрываю настройки). Но проблема не в этом (или не только в этом, т.к.):
  • Под рукой был Xiaomi Redmi 3S, попробовал с ним — там галочка отладка по USB не слетала.
  • В редакторе Edit > Project Settings > Editor моё устройство не высветилось (ни одно, ни второе). Поставил: Любое Android устройство.
  • ПК подтянул какие-то дрова из воздуха к Xiaomi, к Honor я ставил HiSuit и разрешал там доступ к HDB. Кстати, забавно, что до включения панели разработчика HiSuit распознавала устройство с ПК, а после стала выдавать, что устройство не подключено. Хотя я проверил — галочка «разрешить доступ к HDB» стоит, а именно этого требует приложуха HiSuit.
  • Кстати, при установке движка я сразу указывал, что мне нужны всякие плюшки для Android. Но в итоге он мне всё равно в консоль писал, что у меня путь до SDK не указан, и надо бы указать.
  • Там, где надо указывать путь к SDK, стояла галочка (sdk установлено вместе с Unity -рекомендуется). Скачал sdk-tools-windows-4333796 с официального сайта и указал путь до него. Консоль начала ругаться, что ей в этой папке не хватает каких-то файлов (строчек просто куча, подозреваю, что SDK установил или неправильно, или не весь, хз).
  • Модель Honor: JSN-L21, что бы это не значило. Само устройство зовётся 8х. Так вот, я пробовал скачивать гугловский USB-драйвер для android и вот эту хрень — JSN-L21 — прописывать в файл android_winusb.inf по гайдику. Не сработало. Может чего-то не так сделал, а может этого мало.

В общем, я весь день вертел это злобное колдунство и так, и этак. Очевидно не хватает скила, и понимания процессов. Если кто-то знает, что делать, подскажите, пожалуйста.

Версия андроид — 9.

Версия Unity — Unity 2019.2.0f1 (64-bit).

Винда — 64-х разрядная на ПК.

Кстати, как сделать, чтобы галочка «Отладка по USB» в Honor не слетала? (Xiaomi под рукой будет не всегда)

Как правильно ставить android-SDK и указывать к нему путь в движке?

UPD: галочка «Отладка по USB» слетает также в Honor 10I.

На 8Х решилось следующим образом: надо комплексно активировать 4 крыжика:

  • Отладка по USB
  • Всегда спрашивать при USB-подключении
  • Разрешить отладку по ADB только при зарядке
  • Проверка приложений по USB

Отсутствие одного из 3-х вспомогательных заставляет «Отладку по USB» слетать.

Прочитал Huawei Horror и задумался…

Есть один дедовский лайфхак:
Качаем Google USB Driver, открываем inf, и в любом девайсе меняем ID девайса на наш ID. Для чайна-девайсов работает только так.

Читайте также:  Телевизор samsung как настроить яркость

Но конечно не совсем понятно, зачем гуглу понадобилось костылить свой драйвер, когда есть UART. ред.

А я так пробовал, и чо-то не вышло. Там точно просто в inf хватит записи?

Конечно, я так уже с 2015 делаю. Открой просто adb и введи adb devices.

В inf смотри, чтобы совпадала архитектура. ред.

Лан, попробую ещё раз.

Мне помогло включить «передачу файлов по usb» вместо «зарядки по usb». Тогда галочка перестала слетать. Но почему-то remote 5 всё равно не работает.

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

У меня все работало на сяоми само без танцев с бубном. ))

ПК подтянул какие-то дрова из воздуха к Xiaomi, к Honor я ставил HiSuit и разрешал там доступ к HDB. Кстати, забавно, что до включения панели разработчика HiSuit распознавала устройство с ПК, а после стала выдавать, что устройство не подключено. Хотя я проверил — галочка «разрешить доступ к HDB» стоит, а именно этого требует приложуха HiSuit.

Не те драйвера, вроде, поищи специальные для ADB. И то что два телефона к пк подключаешь — тоже не особо. ред.

Источник

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:

  • Сенсорный ввод
  • Акселерометр
  • Гироскоп
  • Потоки камеры устройства
  • Compass
  • GPS

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:

  • Unity Project (requires custom building) from the Asset Store:
  • Android App from Google Play:
  • iOS App from the 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:

  • Reconnect the device.
  • Restart the device.
  • Go to the Editor settings (menu: Edit > Project Settings > Editor) and in the Unity Remote settings, briefly switch the device to Any Android Device and then back to Any iOS Device.
  • Restart the Unity editor.
  • Quit the Unity editor, open the Terminal and execute the command killall unityiproxy . Then, restart the editor again.

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

Источник

Debugging C# code in Unity

Using a debugger allows you to inspect your source code while your application or game is running. Unity supports debugging of C# code using the following code editors:

Читайте также:  Как настроить обороты вентилятора блока питания

Visual Studio (with the Visual Studio Tools for Unity plug-in)

Visual Studio for Mac

Visual Studio Code

Although these code editors vary slightly in the debugger features they support, all provide basic functionality like break points, single stepping, and variable inspection.

Managed code debugging in Unity works on all platforms except WebGL A JavaScript API that renders 2D and 3D graphics in a web browser. The Unity WebGL build option allows Unity to publish content as JavaScript programs which use HTML5 technologies and the WebGL rendering API to run Unity content in a web browser. More info
See in Glossary . It works with both the Mono and IL2CPP A Unity-developed scripting back-end which you can use as an alternative to Mono when building projects for some platforms. More info
See in Glossary scripting backends A framework that powers scripting in Unity. Unity supports three different scripting backends depending on target platform: Mono, .NET and IL2CPP. Universal Windows Platform, however, supports only two: .NET and IL2CPP. More info
See in Glossary .

Configuring the code editor

Visual Studio (Windows)

The Unity Editor installer includes an option to install Visual Studio with the Visual Studio Tools for Unity plug-in A set of code created outside of Unity that creates functionality in Unity. There are two kinds of plug-ins you can use in Unity: Managed plug-ins (managed .NET assemblies created with tools like Visual Studio) and Native plug-ins (platform-specific native code libraries). More info
See in Glossary . This is the recommended way to set up Visual Studio for debugging with Unity.

If Visual Studio is already installed on your computer, use its Tools > Get Tools and Features… menu to locate and install the Visual Studio Tools for Unity plug-in.

Visual Studio for Mac

The Unity Editor installer includes an option to install Visual Studio for Mac. This is the recommended way to set up Visual Studio for Mac for debugging with Unity.

If Visual Studio for Mac is already installed on your computer, use its Extension Manager to locate and install the Visual Studio Tools for Unity plug-in.

JetBrains Rider

The default installation of JetBrains Rider can debug code in Unity on Windows or Mac. Please visit the JetBrains website to install it.

VS Code

VS Code requires you to install an extension to debug code in Unity. Please follow the instructions specific to this extension to install it.

Specifying the External Script Editor in Unity

Once you’ve installed a code editor, go to Preferences > External Tools and set the External Script Editor to your chosen code editor.

Debugging in the Editor

You can debug C# code that is running in the Unity Editor while the Unity Editor is in Play Mode.

To debug in the Editor, you need to set the Editor’s Code Optimization mode to Debug Mode, then you can attach a code editor with a debugging feature.

To change the Code Optimization mode, select the Debug Button in the bottom right of the Unity Editor Status Bar.

The Debug Button in the bottom right of the Unity Editor Status Bar

Unity’s Code Optimization setting has two modes.

  • Debug Mode, which you can use to attach external debugger software, but gives slower C# performance when you run your Project in Play Mode in the Editor.
  • Release Mode, which gives faster C# performance when you run your Project in Play Mode in the Editor, but you cannot attach any external debuggers.

When you click the Debug button in the status bar, a small pop-up window opens which contains a button you can use to switch modes. It also displays information about the current mode, and describes what happens if you switch modes.

The Debug Mode popup, which shows the current mode, allows you to switch modes, and describes what happens if you switch mode.

To change which mode the Unity Editor starts up in, go to Edit > Preferences > General > Code Optimization On Startup.

In Preferences, you can change the Code Optimization mode that Unity starts in.

You can also override the mode that the Editor starts up in, or turn off the debugger listen socket. To do this, use the following command line arguments when you launch the Editor:

  • -releaseCodeOptimization Starts the Editor in release code optimization mode.
  • -debugCodeOptimization Starts the Editor in debug code optimization mode.
  • -disableManagedDebugger Starts the Editor with the debugger listen socket disabled.

Setting breakpoints and attaching to the Editor

In your external code editor, set a breakpoint in the code editor on a line of script code where the debugger should stop. For example, in Visual Studio, click on the column to the left of your code, on the line you want to stop the debugger (as shown below). A red circle appears next to the line number and the line is highlighted.

A breakpoint set in Visual Studio

Next, attach the code editor to the Unity Editor. This option varies depending on the code editor, and is often a different option from the code editor’s normal debugging process. In Visual Studio, the option looks like this:

The Attach To Unity button in Visual Studio

Some code editors may allow you to select an instance of Unity to debug. For example, in Visual Studio, the Debug > Attach Unity Debugger option exposes this capability.

Visual Studio listing the current instances of Unity available to debug. In this example, there is one instance running in the Editor and one instance running as an Android Plyaer

When you have attached the code editor to the Unity Editor, return to the Unity Editor and enter Play Mode. When the code at the breakpoint is executed, the debugger will stop, for example:

The debugger in Visual Studio when it has stopped at a breakpoint

While the code editor is at a breakpoint, you can view the contents of variables step by step. The Unity Editor will be unresponsive until you choose the continue option in the debugger, or stop debugging mode.

Debugging in the Player

To debug script code running in a Unity Player, ensure that you enable the “Development Build” and ”Script Debugging” options before you build the Player (these options are located in File > Build Settings). Enable the “Wait For Managed Debugger” option to make the Player wait for a debugger to be attached before it executes any script code.

Читайте также:  Как настроить color screen calendar model 8190

To attach the code editor to the Unity Player, select the IP address (or machine name) and port of your Player. In Visual Studio, the drop-down menu on the “Attach To Unity” option looks like this:

The Debug > Attach Unity Debugger option looks like this:

Make sure you attach the debugger to the Player, and not to the Unity Editor (if both are running). When you have attached the debugger, you can proceed with debugging normally.

Debugging on Android and iOS devices

Android

When debugging a Player running on an Android device, connect to the device via USB or TCP. For example, to connect to an Android device in Visual Studio (Windows), select Debug > Attach Unity Debugger option. A list of devices running a Player instance will appear:

In this case, the phone is connected via USB and Wi-Fi on the same network as the workstation running the Unity Editor and Visual Studio.

Android on Chrome OS

Unity cannot automatically discover Chrome OS devices. To initiate a connection, connect to the device through Android Debug Bridge (adb) by its IP address and then enter the IP address manually in the debugger dialog.

When debugging a Player running on an iOS device, connect to the device via TCP. For example, to connect to an iOS device in Visual Studio (Mac), select Debug > Attach Unity Debugger option. A list of devices running a Player instance will appear:

Ensure that the device only has one active network interface (Wi-Fi recommended, turn off cellular data) and that there is no firewall between the IDE and the device blocking the TCP port (port number 56000 in the above screenshot). Debugging over USB is not supported with iOS Apple’s mobile operating system. More info
See in Glossary .

Troubleshooting the debugger

Most problems with the debugger occur because the code editor is unable to locate the Unity Editor or the Player. This means that it can’t attach the debugger properly. Because the debugger uses a TCP connection to the Editor or Player, connection issues are often caused by the network. Here are a few steps you can take to troubleshoot basic connection issues.

Ensure you attach the debugger to the correct Unity instance

You can attach code editor to any Unity Editor or Unity Player on the local network that has debugging enabled. When attaching the debugger to ensure that you are attaching to the correct instance. If you know the IP address or machine name of the device on which you are running the Unity Player, this helps to locate the correct instance.

Verify the network connection to the Unity instance

The code editor uses the same mechanism to locate a Unity instance to debug as the Unity Profiler A window that helps you to optimize your game. It shows how much time is spent in the various areas of your game. For example, it can report the percentage of time spent rendering, animating or in your game logic. More info
See in Glossary uses. If the code editor cannot find the Unity instance you expect it to find, try to attach the Unity Profiler to that instance. If the Unity Profiler cannot find it either, a firewall might exist on the machine which you are running the code editor on or the machine which you are running the Unity instance on (or possibly both). If a firewall is in place, see the information about firewall settings below.

Ensure the device has only one active network interface

Many devices have multiple network interfaces. For example, a mobile phone may have both an active cellular connection and an active Wi-Fi connection. To properly connect the debugger for TCP, the IDE needs to make a network connection to the correct interface on the device. If you plan to debug via Wi-Fi, for example, make sure you put the device in airplane mode to disable all other interfaces, then enable Wi-Fi.

You can determine which IP address the Unity Player is telling the IDE to use by looking in the Player Log The .log file created by a Standalone Player that contains a record of events, such as script execution times, the compiler version, and AssetImport time. Log files can help diagnose problems. More info
See in Glossary . Look for a part of the log like this:

This message indicates the IDE will try to use the IP address 10.0.1.152 and port 56000 to connect to the device. This IP address and port must be reachable from the computer running the IDE.

Check the firewall settings

The Unity instance communicates with the code editor via a TCP connection. On most Unity platforms, this TCP connection occurs on an arbitrarily chosen port. Normally, you should not need to know this port, as the code editor should detect it automatically. If that does not work, try to use a network analysis tool to determine which ports might be blocked either on the machine where you are running the code editor, or the machine or device where you are running the Unity instance. When you find the ports, make sure that your firewall allows access to both the port on the machine running the code editor, and the machine running the Unity instance.

Verify the managed debugging information is available

If the debugger does attach, but breakpoints don’t load, the debugger may not be able to locate the managed debugging information for the code. Managed code debugging information is stored in files named .pdb, next to the managed assembly (.dll file) on disk.

When the correct preferences and build options are enabled (see above, Unity will generate this debugging information automatically. However, Unity cannot generate this debugging information for managed plugins in the Project. It is possible to debug code from managed plugins if the associated .pdb files are next to the managed plugins in the Unity project on disk.

Prevent the device from locking

If the device you are using to debug the application has a screen lock, make sure this is disabled. Screen locks cause the debugger to disconnect, and prevent it from re-connecting. It is best to avoid locking the screen during managed code debugging. If the screen does lock, you should restart the application on the device before the debugger can connect again.

Источник

Оцените статью