Unity3d开发性能优化-性能分析工具Profiler使用

Unity3d 自带非常好用的性能分析工具:Profiler

以下为Android平台下Unity3d应用的Profiler的使用步骤:
1. 发布Untiy Android APK时,勾选“Development Build”和“AutoConnect Profiler”选项
Unity3d开发性能优化-性能分析工具Profiler使用_第1张图片
2. 将Android设备采用adb的方式与PC相连
3. 开始运行应用后,点击Unity菜单栏-Window-Profiler,选择ActiveProfiler -
Unity5.5: [email protected]:54999
Unity5.6: [email protected]:34999
一定要保证防火墙中54998 to 55511(Untiy5.6:34999)的端口是打开状态,我一般所有端口都打开了。
4. 打开CMD,输入:
adb start-server
adb forward tcp:54999 localabstract:Unity-xxx.xxx.xxx (Untiy5.5)
(Unity5.6: adb forward tcp:34999 localabstract:Unity-xxx.xxx.xxx)
(xxx.xxx.xxx指的是Unity应用程序的Bundle Identifier,也就是APK的包名)

使用教程参考官方教程:
https://docs.unity3d.com/Manual/ProfilerWindow.html
Android

here are two methods to enable remote profiling on Android devices: WiFi or ADB.

For WiFi profiling, follow these steps:

  1. Make sure to 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 Mac or PC via cable. Check the Development Build and Autoconnect Profiler checkboxes in Unity’s Build Settings dialog box, and click on Build & Run in the Unity Editor.
  4. When the app launches on the device, open the Profiler window in the Unity Editor (Menu: Window > Profiler).
  5. If the Unity Editor fails to autoconnect to the device, select the appropriate device from the Profiler window Active Profiler drop down menu.

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

For ADB profiling, follow these steps:

  • Attach your device to your Mac or PC via cable and make sure ADB recognizes the device (i.e. it shows in adb devices list).
  • In the Unity Editor’s Build Settings dialog box (menu: File__>__Build
    Settings…), check the Development Build__checkboxcheck and select Build & Run__.
  • When the app launches on the device, open the Profiler window in the
    Unity Editor (Menu: Window > Profiler).
  • Select the AndroidProfiler([email protected]:54999) from the Profiler
    Window Active Profiler drop down menu. Note: The Unity Editor
    automatically creates an adb tunnel for your application when you
    click on Build & Run. If you want to profile another application or
    you restart the adb server you have to setup this tunnel manually. To
    do this, open a Terminal window / CMD prompt and enter:

    adb forward tcp:54999 localabstract:Unity-{insert bundle identifier here}
    Note: The entry in the drop down menu is only visible when the selected target is Android.

    If you are using a firewall, you need to make sure that ports 54998 to 55511 are open in the firewall’s outbound rules - these are the ports used by Unity for remote profiling.

你可能感兴趣的:(Unity3d)