Unity之Profiler Your Application

Profiling your application

要在目标发布平台上配置您的应用程序,请将目标设备连接到您的网络或通过电缆直接连接到您的计算机. 您还可以在Unity编辑器中直接对应用程序进行概要分析,以便在开发应用程序期间大致分析结果。

方式:

发布出来的的程序,装在预定平台上,运行,打开unity编辑器,预定平台和分析数据的电脑要在同一个局域网下,或者通过网线连接到分析数据的电脑上,unity编辑器会自动识别同一个局域网下,运行的所用应用程序,你可以选择分析哪个平台下的数据

Unity之Profiler Your Application

Remote profiling

远程配置:

您只能以Development Build发布程序, Build Settings (File > Build Settings) 选择目标平台,打开 Development Build

你也可以勾选Autoconnect Profiler,这样发布之后打开unity,会自动连接目标平台,IP地址就是你在Profiler-->Editor下填写的ip地址,这样就是目标平台改变了

Unity之Profiler Your Application

Unity之Profiler Your Application

 

当你运行你的应用程序时,播放器中的Editor下拉列表中,会显示在同一个局域网下,运行的所有该应用程序,你可以通过ip地址或者名字来区分它们 (for example, iPhonePlayer (Toms iPhone)).

Unity之Profiler Your Application

  选择其中的一个平台分析记录数据,如果你选中Autoconnect to Profiler , Unityh会自动在程序运行时收集数据

在应用程序运行时持续收集数据, 需要打开Run In Background 设置在Player Settings中
(menu: Edit > Project Settings > Player > Resolution and Presentation).

 

WebGL

你可以在WebGL中使用Unity分析器,但是你不能通过WebGL附加到正在运行的播放器上。这是因为WebGL使用WebSockets进行通信,它不允许在浏览器端进行传入连接. To attach to a running player, you need to enable the Autoconnect Profiler checkbox in Build Settings (menu: File > Build Settings). Unity cannot profile draw calls for WebGL.

Profiling on mobile devices

IOS和Android设备都支持通过网络进行远程分析。如果您正在使用防火墙,请在防火墙的出站规则中打开端口54998到55511。这些是Unity用于远程分析的端口。

Note: 有时,当您设置远程配置时,Unity编辑器可能不会自动连接到设备。如果发生这种情况,您可以手动启动分析器连接。为此,在Profiler窗口中选择Attach To Player下拉菜单并选择适当的设备。

您还可以将目标设备直接插入计算机,以避免网络或连接问题。

iOS remote profiling

To enable remote profiling on iOS devices, follow these steps:

  1. Connect your iOS device to your WiFi network. The Profiler uses a local WiFi network to send profiling data from your device to the Unity Editor.
  2. Attach your device to your computer via cable. Go to the Build Settings (menu: File > Build Settings), enable the Development Build and Autoconnect Profiler checkboxes, then select Build & Run.
  3. When the application launches on the device, open the Profiler window in the Unity Editor (menu: Window > Analysis > Profiler).

Android remote profiling

Android devices support two methods of remote profiling: via WiFi or through Android Debug Bridge (adb).

For WiFi profiling, follow these steps:

  1. Disable mobile data on your Android device.
  2. Connect your Android device to your WiFi network. The Profiler uses a local WiFi network to send profiling data from your device to the Unity Editor.
  3. Attach your device to your computer via cable. Go to the Build Settings (menu: File > Build Settings), enable the Development Build and Autoconnect Profiler checkboxes, then select Build & Run.
  4. When the application launches on the device, open the Profiler window in the Unity Editor (menu: Window > Analysis > Profiler).

Note: The Android device and host computer that is running the Unity Editor must both be on the same subnet for device detection to work.

For Android Debug Bridge (adb) profiling, follow these steps:

  1. Attach your device to your computer via cable and make sure that it shows in the adb
    devices list.
  2. Go to the Build Settings (menu: File > Build Settings), enable the Development Build checkbox, and then select Build & Run
  3. When the application launches on the device, open the Profiler window in the Unity Editor (menu: Window > Analysis > Profiler).
  4. From the Attach to Player drop-down menu, select AndroidProfiler([email protected]:34999). The entry in the drop-down menu is only visible when the selected target is Android.

The Unity Editor automatically creates an adb tunnel for your application when you select Build & Run. If you want to profile another application, or you restart the adb server, you have to configure this tunnel manually. To do this, open a Terminal window or CMD prompt and enter:

adb forward tcp:34999 localabstract:Unity-{insert bundle identifier here}

To use Deep Profiling with an Android build, you need to enable the Mono Scripting Backend setting in the Android Player Settings (menu: Edit > Project Settings > Player > Android > Other Settings) and enter the following to start the game through an adb command:

~$ adb shell am start -n {insert bundle identifier here}/com.unity3d.player.UnityPlayerActivity -e 'unity' '-deepprofiling'