1. 程式人生 > >unity3d 官方文件的除錯方法

unity3d 官方文件的除錯方法

The Unity Debugger lets you inspect your code at runtime. For example, it can help you determine when a function is called and with which values. Furthermore, it allows you to look at the value of scripts' variables at a given time while running your game. You can locate bugs or logic problems in your scripts by executing them step by step.

Unity除錯,可以讓你在執行時檢查你的程式碼。例如,他可以幫助你確定某個函式被呼叫時的值。此外,他允許你在給定時間內同時執行你的遊戲觀看指令碼中變數的值。你可以通過執行這些步驟在指令碼中查詢bug或邏輯問題。

Unity uses the MonoDevelop IDE to debug the scripts in your game. You can debug all the languages supported by the engine (JavaScript, C#, and Boo).

Unity使用MonoDevelop IDE來除錯你遊戲中的指令碼。你可以除錯引擎(Javascript,C#和Boo)支援的所有語言。

Note that the debugger has to load all your code and all symbols, so bear in mind that this can have a small impact on the performance of your game during execution. Typically, this overhead is not large enough to affect the game framerate.

請注意:偵錯程式會載入你所有的程式碼和所有的符號,所以牢記,這在你遊戲執行的過程中會對遊戲的效能有一些小的影響。通常情況下,這種開銷不足以大到影響遊戲的幀率的。

MonoDevelop window debugging a script in unity.
MonoDevelop在Unity除錯指令碼的視窗。

Debugging in Unity.(在Unity中進行除錯)

On Windows, users must choose to install MonoDevelop as part of the Unity installation (selected by default).

在Windows上,使用者必須選擇MonoDevelop作為(預設情況下選中)Unity安裝的一部分。

  • If you haven't used MonoDevelop with your project before, synchronize your MonoDevelop project. This will open your project inside MonoDevelop. 
    如果在你的專案之前沒有使用MonoDevelop,那麼同步你的MonoDevelop專案。這將會在你的MonoDevelop中開啟專案。

  • Set the necessary breakpoints on your scripts by clicking the lines that you want to analyze. 
    通過單擊線在你的指令碼中對你想要分析的地方設定必要的斷點。

  • Launch Unity or your player. 啟動Unity或者播放器
    • Unity: Ensure you have "Editor Attaching" checked in the Preferences window.(這裡已經改了)
      Unity:確保在Preferences視窗中勾選了Editor Attaching。在External Tools下面
    • Players: Ensure that you have built your player with the "Development build" and "Allow script debugging" options enabled. For webplayers, additionally check that the development release channel setting is enabled on the player's context menu (right click on Windows or cmd-click on Mac OSX)
      播放器:確保在你編譯播放器是啟用了"Development Build" 和"Allow Script debugging"。
    • 這一步很重要啊!!!這裡加個圖片!這個不設定的話,不能除錯的!!!
    • unity3d <wbr>官方文件的除錯方法

  • Open your project in MonoDevelop. 
    在MonoDevelop中開啟專案。
  • In MonoDevelop, click the Attach button in the toolbar, or choose Attach from the Run menu. 
    在MonoDevelop中單擊工具欄中的附加按鈕,或者選擇Run選單中的Attach。
  • From the dialog that appears, choose the item you wish to debug. 
    從出現的對話方塊中,選擇你要除錯的專案。
  • Notes: 注意:
    • Currently supported debugging targets: Unity editors, desktop standalone players, Android and iOS players 
      目前支援除錯的目標:Unity編輯器,桌面獨立播放器,Android和iOS播放器。
    • If your player is set not to run in the background (the default), you may need to focus your player for a few seconds in order for it to appear in the list. 
      如果播放器設定為不要在後臺執行(預設),你可能需要關注你的播放器幾秒,以便他出現在列表中。
    • Android and iOS players need to have networking enabled when script debugging is enabled. All players need to be on the same network subnet as the computer running MonoDevelop. 
      Android和iOS播放器在除錯指令碼時需要啟用網路。所有的播放器都需要執行在MonoDevelop的計算機相同網路的子網中。

  • When you enter play mode, your script code will execute in the debugger. 
    當你按下播放模式,你的指令碼程式碼將會在偵錯程式中被執行。
  • When a breakpoint occurs, script execution will stop, and you will be able to use MonoDevelop to step over, into, and out of your script methods, inspect your variables, examine the call stack, etc.
    當斷點發生時,停止執行指令碼,你可以使用MonoDevelop去單步除錯進出你指令碼中的方法,檢查變數,檢查堆疊等。
    • Note: When you're done debugging a toplevel method (e.g. Update()), or you just want to jump to the next breakpoint, you will experience better debugger performance by using the Continue command instead of stepping out or over the end of your function. 
      注意:當你除錯完一個頂層的方法(例如:Update()),或者你只想跳到下一個斷點,你使用繼續命令而不是跨出或超過函式會讓你體會到更好的除錯效能。

  • When you're done debugging, click the Detach or Stop buttons in the toolbar, or choose Detach or Stop from the Run menu. 
    當你完成除錯是,在工具欄上單擊"Detach"或"Stop"按鈕,或者從Run選單中選擇 "Detach"或 "Stop"。

Hints. 提示

  • If you add a watch to the this object, you can inspect the internal values (position, scale, rotation...) of the GameObject to which the script is attached. 
    如果你新增物件到監視時,你可以檢查該物件上指令碼中內部的值(位置,縮放,旋轉。。。)。

iOS remote debugging instructions
iOS遠端除錯的說明

In addition to the instructions described above, Unity iOS applications require some additional steps for successful debugging:

除以上所述介紹,Unity中的iOS應用程式要成功除錯,還需要一些附加的步驟:

  1. Attach your iDevice to your WiFi network (the same requirement as for remote profiling). 
    將你的iDevice附加到你的WiFi網路(對於遠端評測有相同的要求)。
  2. Hit build & run in the Unity editor. 
    在Unity編輯器中點選 build&run。
  3. When the application builds, installs& launches via Xcode, click Stop in Xcode. 
    當應用程式生成,安裝以及通過Xcode啟動,在Xcode中單擊停止。
  4. Manually find & launch your application on your iDevice. (Note: if the application is launched via Xcode you won't be able to resume after reaching a breakpoint). 
    在iDevice中手動查詢和啟動應用程式。(注意:如果應用程式時候通過Xcode啟動的,在到達斷點之後你將無法恢復。)
  5. When the app is running on the device, switch to MonoDevelop and click on the attach icon in the debugging toolbar. Select your device from the available instances list (if there are several instances shown, then select the bottom one). 
    當應用程式執行在裝置上時,切換到MonoDevelop,並單擊除錯工具欄中的連線圖示。從可用例項列表中選擇你的裝置(如果顯示有幾個例項,選擇底部的那個)。

相關推薦

unity3d 官方除錯方法

The Unity Debugger lets you inspect your code at runtime. For example, it can help you determine when a function is called and with which values. Furtherm

Unity3D 官方 UGUI總覽 自動佈局元件的介紹

版本:unity 5.6  語言:C# 總起: 自動佈局元件可以根據元素的內容自動調節元素的佈局,在和滾動列表配合顯示動態元素時比較方便。 擁有Layout Element指令碼的是子元素,放在相應的Layout Group父節點上,Layout Group就會根據其W

Unity3D 官方 平臺特殊化之Android

版本:unity 5.6  語言:C#  總起: Android平臺,雖然與IOS開發類似,但因為其硬體沒有完全的標準化,所以會出現各式各樣的問題。這一點在官方文件的第一段就提到了。 Unity Android基本環境的搭建還是比較容易的: 1.Unity本身沒有下載A

Unity3D 官方 2D遊戲的起始3 2D物理續 Collider、關節、效應器

版本:unity 2017.1  語言:C# 總起: 之前介紹了剛體元件,這邊要把剩下物理元件介紹完。Collider大家平時都在用,關節可能少點,實現特定功能會用到,至於效應器,大家跟我一起來看看這個東西有什麼作用吧。 Collider 2D: 用於定義2D物體的形狀

MySQL CPU 使用率高的原因和解決方法(來自aliyun官方)

  使用者在使用 MySQL 例項時,會遇到 CPU 使用率過高甚至達到 100% 的情況。本文將介紹造成該狀況的常見原因以及解決方法,並通過 CPU 使用率為 100% 的典型場景,來分析引起該狀況的原因及其相應的解決方案。 常見原因 系統執行應用提交查詢(包括資料修改操

關於TP5檢視分離到根目錄的解決方法 原有: 為了方便前端開發,我想把檢視(view)部分分離出來專門給前端進行修改 過程:在進行檢視設定分離的過程遇到了問題 參考了官方http://www

關於TP5檢視分離到根目錄的解決方法原有: 為了方便前端開發,我想把檢視(view)部分分離出來專門給前端進行修改過程:在進行檢視設定分離的過程遇到了問題參考了官方文件http://www.kancloud.cn/manual/thinkphp5/119298後進行修改

使用Android Studio進行NDK開發和除錯(gradle-experimental之官方的翻譯說明)

版本更新 環境要求 Gradle(參照三裡邊的版本要求) Android NDK r10e Build Tool在19.0.0以上的SDK Gradle版本要求 不同版本的Experimental Plugin需要不同版本的gradle

Python官方3.2教程--方法定義-預設引數值

2.7.1 預設引數值 最有用的形式就是給一個或多個變數制定預設值。這種方法可以建立一個允許呼叫時比定義時需要更少的引數。例如: def ask_ok(prompt, retries=4, complaint=’Yes or no, please!’): while Tr

coredump中添加oat方法

ldr pro cat 結束 sass 偏移 rom oat starting coredump默認不會dump文件映射, 而我們如果要調試oat問題,需要將boot.oat等文件直接加載到core文件裏。 這樣就能方便的在gdb中查詢oat文件中的內容了。 本文將介紹如何

Linux操作系統下/etc/hosts配置方法

主機名 進行 問題 解釋 很快 中一 linux 同時 包括 1、關於/etc/host,主機名和IP配置文件   Hosts - The static table lookup for host name(主機名查詢靜態表)   hosts文件是Linux系統中一個負責

android makefile批量拷貝方法

-m 批量 mod font ring div 復制 -s packages 該方法是shell 和makefile組合使用 wallpapers := $(shell ls packages/apps/hyst_apps/NewBingoLauncher_C/defa

Windows和Mac連接公司內網共享方法

windows 用戶名 文件夾 共享 MAC連接共享文件方法:(Windows方法在後邊)1. 先在 Mac 系統中打開 Finder 應用,如圖所示2. 打開 Finder 窗口以後,請按鍵盤上的 command+K 組合鍵,如圖所示3. 隨後我們在框框中輸入地址:smb://f

Java中獲取資源方法總結

tco doget 技術 resource images 磁盤 response linux exception 這裏總結3中方法獲取資源文件的 ServletContext Class ClassLoader 文件的位置 1. ServletC

上傳實現方法

exception -c 實現 public input res nec tco -type public static String formUpload(String urlStr, Map<String, String> textMap, Map<S

vm 安裝centos 7無網卡配置解決方法

解決方案 network 配置文件 操作系統 failed 問題描述:朋友新安裝了centos7,發現無網卡配置文件,另外network服務是failed狀態。找到我求助嘗試解決方案1、關閉NetworkManager,自己創建ifcfg-eth0配置文件,錯誤依舊嘗試解決方案2、配置文件

java讀取TXT方法

param 之間 cin stream bsp java讀取 amr imp void java讀取txt文件內容。可以作如下理解: 首先獲得一個文件句柄。File file = new File(); file即為文件句柄。兩人之間連通電話網絡了。接下來可以開始打電話

打開DWG格式哪個方法正確

  CAD文件如今在許多的領域當中都會使用到,DWG格式文件作為最常使用的CAD文件圖紙,自然經常會被我們使用到,如果我們想要對DWG格式文件進行查看和編輯,那麽我們應該怎麽進行操作呢?想要打開DWG格式文件,就需要使用專業的CAD文件編輯器打開。那麽打開DWG格式文件正確的方法是什麽? 一、什麽軟件可

ARM開發板搭建NFS網絡系統方法

安裝 http ext 博客 主機 文件 oot ini first 前邊 已經提到過吧vmare的IP改成了靜態IP,對於上網來說,這個是個麻煩的事。現在重新配置Vmware的IP VMware-Edit-Virtual network editor 選擇PC機的無線網

JS下載方法

size 不同類 doc html save pre 超級鏈接 htm 類型 對於超級鏈接標簽href設置不同的文件路徑,不同的瀏覽器處理方式都不同,有的瀏覽器會打開文件,有的則會直接下載文件,最近在項目中需要實現不同類型的文件均需要下載的需求,通過學習,根據HTML5中為

VC2010 利用 def 生成 dll 方法

urn fontsize std eas fcm rar 文件的 利用 發現 近期有個需求,要生成一個dll 文件。文件裏的函數都是採用 stdcall 函數調用約定,可是不希望函數名被修飾(add 被修飾成 [email protected]/* */)。