android下調試unity3d應用

來源:互聯網
上載者:User

標籤:android   style   blog   http   color   使用   

原地址:http://blog.csdn.net/armoonwei/article/details/7032455

目前貌似不支援斷點調試,但可以通過日誌列印(logcat)來跟蹤。 在android SDK中有個adb工具,使用此工具來跟蹤啟動並執行android應用:adb logcat  啟動logcat,並將裝置上啟動並執行android應用的運行時資訊全部列印出來。 adb logcat -s Unity  如果只想列印Unity的輸出資訊,使用此命令。 adb logcat -d > logcat.txt  將列印資訊輸出為檔案。 當然,更直接的做法是在應用中整合自己的調試資訊視窗,將如下代碼關聯到一個gameobject:[csharp] view plaincopy<p>using UnityEngine;  using System.Collections;</p><p>public class GuiTextDebug : MonoBehaviour   {   private float windowPosition = -440.0f;   private int positionCheck = 2;   private static string windowText = "";   private Vector2 scrollViewVector = Vector2.zero;   private GUIStyle debugBoxStyle;      private float leftSide = 0.0f;   private float debugWidth = 420.0f;      public bool debugIsOn = false;      public static void debug(string newString)   {    windowText = newString + "\n" + windowText;    UnityEngine.Debug.Log(newString);   }       void Start()       {    debugBoxStyle = new GUIStyle();    debugBoxStyle.alignment = TextAnchor.UpperLeft;    leftSide = 120;   }          void OnGUI()       {    if (debugIsOn)           {     GUI.depth = 0;       GUI.BeginGroup(new Rect(windowPosition, 40.0f, leftSide, 200.0f));          scrollViewVector = GUI.BeginScrollView(new Rect (0, 0.0f, debugWidth, 200.0f),                                                      scrollViewVector,                                                      new Rect (0.0f, 0.0f, 400.0f, 2000.0f));     GUI.Box(new Rect(0, 0.0f, debugWidth - 20.0f, 2000.0f), windowText, debugBoxStyle);     GUI.EndScrollView();          GUI.EndGroup ();          if (GUI.Button(new Rect(leftSide, 0.0f,75.0f,40.0f), "調試"))              {      if (positionCheck == 1)                  {       windowPosition = -440.0f;       positionCheck = 2;      }      else                   {       windowPosition = leftSide;       positionCheck = 1;      }     }          if (GUI.Button(new Rect(leftSide + 80f,0.0f,75.0f,40.0f),"清除"))              {      windowText = "";     }    }   }  }  </p>  

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.