Android开发 调试环境
我们这里有3种调试方法,Unity Remote,Android Studio和第三方模拟器
准备工作
(1)Android Studio:安装Google USB Driver
(2)手机安装Unity Remote
安装Unity Remote后,可以将手机与PC用USB线连接,在Unity界面运行,并在手机上显示画面,这样可以不用打包就能测试大部分功能,但是缺点是不能测试全部功能,有一些还是检测不到的。
调试
(1)使用Unity Remote调试
首先设置Unity中的Editor Settings,依次打开Edit > Project Settings > Editor
打开手机,确保开发人员选项打开,并且在USB调试模式下,打开Unity Remote,然后启动Unity项目,手机上就会显示
(2)使用AVD + [Logcat] 调试(Android Virtual Device)
打开Android Studio,选择Tools > AVD Manager
创建一个虚拟设备
这个根据需要选择型号
这一步注意,选择一个稳定的,存在的
创建好后如下
选择运行,就出现一个我们创建好的虚拟设备
最后,在Unity中Build And Run,以前是Bulid,这里会创建好一个apk,并且在创建的时候unity会搜索连接的Android设备,并将apk安装上去。这个时候我们的虚拟设备上就运行了这个包。
在虚拟设备运行的时候,可以在这里选择看到Android的打印显示
(3)使用真机 + [Logcat] 调试
和第2种方法不一样的事,这里不适用虚拟设备,直接使用我们的手机来调试。手机用数据线和电脑连接,和第2种方法一样的打包,但是这里会在我们的手机上面安装一个包运行。同样可以在Android Studio中看到Logcat
(4)使用模拟器调试
安装模拟器,将打出的包安装上去,运行就行了。
移动端相关API:
using UnityEngine;
using UnityEngine.UI;
public class Test : MonoBehaviour
{
public Text infoText;
string platform = string.Empty;
string info = string.Empty;
void Update()
{
info = string.Empty;
//使用预编译的宏命令检测平台
//Editor模式下目标平台选Android也会触发UNITY_ANDROID的宏
#if UNITY_ANDROID
platform = "UNITY_ANDROID";
#elif UNITY_EDITOR
platform = "UNITY_EDITOR";
#endif
Debug.Log("platform : " + platform);
info += "platform : " + platform + "\n";
//使用Application.platform检测平台
Debug.Log("platform : " + Application.platform);
info += "platform : " + Application.platform + "\n";
//获取当前设备分辨率
Debug.Log("currentResolution : " + Screen.currentResolution);
info += "currentResolution : " + Screen.currentResolution + "\n";
//获取当前DPI
Debug.Log("dpi : " + Screen.dpi);
info += "dpi : " + Screen.dpi + "\n";
//获取是否全屏
Debug.Log("fullScreen : " + Screen.fullScreen);
info += "fullScreen : " + Screen.fullScreen + "\n";
//获取游戏窗口的宽高
Debug.Log("height : " + Screen.height);
info += "height : " + Screen.height + "\n";
Debug.Log("width : " + Screen.width);
info += "width : " + Screen.width + "\n";
//获取屏幕方向
Debug.Log("orientation : " + Screen.orientation);
info += "orientation : " + Screen.orientation + "\n";
//获取屏幕超时时间(仅在移动端有效)
Debug.Log("sleepTimeout : " + Screen.sleepTimeout);
info += "sleepTimeout : " + Screen.sleepTimeout + "\n";
//任意键按下
Debug.Log("anyKey : " + Input.anyKey);
info += "anyKey : " + Input.anyKey + "\n";
//获取最后一次加速度计报告的加速度
Debug.Log("acceleration : " + Input.acceleration);
info += "acceleration : " + Input.acceleration + "\n";
//获取本帧加速度计报告的次数
Debug.Log("accelerationEventCount : " + Input.accelerationEventCount);
info += "accelerationEventCount : " + Input.accelerationEventCount + "\n";
//获取本帧加速度计的所有报告信息
for (int i = 0; i < Input.accelerationEvents.Length; i++)
{
Debug.Log("accelerationEvents" + i + " : " + Input.accelerationEvents[i].acceleration + " , " + Input.accelerationEvents[i].deltaTime);
info += "accelerationEvents" + i + " : " + Input.accelerationEvents[i].acceleration + " , " + Input.accelerationEvents[i].deltaTime + "\n";
}
//获取电子罗盘向量
Debug.Log("compass : " + Input.compass.rawVector);
info += "compass : " + Input.compass.rawVector + "\n";
//获取设备方向
Debug.Log("deviceOrientation : " + Input.deviceOrientation);
info += "deviceOrientation : " + Input.deviceOrientation + "\n";
//获取陀螺仪重力
Debug.Log("gyro : " + Input.gyro.gravity);
info += "gyro : " + Input.gyro.gravity + "\n";
//获取位置服务状态
Debug.Log("location : " + Input.location.status);
info += "location : " + Input.location.status + "\n";
//获取设备是否带有鼠标
Debug.Log("mousePresent : " + Input.mousePresent);
info += "mousePresent : " + Input.mousePresent + "\n";
//获取平台是否支持多点触控
Debug.Log("multiTouchEnabled : " + Input.multiTouchEnabled);
info += "multiTouchEnabled : " + Input.multiTouchEnabled + "\n";
//获取是否支持笔触(可检测压感、触摸夹角等)
Debug.Log("stylusTouchSupported : " + Input.stylusTouchSupported);
info += "stylusTouchSupported : " + Input.stylusTouchSupported + "\n";
//获取是否支持压感
Debug.Log("touchPressureSupported : " + Input.touchPressureSupported);
info += "touchPressureSupported : " + Input.touchPressureSupported + "\n";
//获取是否支持触摸
Debug.Log("touchSupported : " + Input.touchSupported);
info += "touchSupported : " + Input.touchSupported + "\n";
if (Input.touchCount > 0)
{
//当前帧的触摸数
Debug.Log("touchCount : " + Input.touchCount);
info += "touchCount : " + Input.touchCount + "\n";
for (int i = 0; i < Input.touchCount; i++)
{
//获取当前Touch对象的一系列属性
Debug.Log("touch" + i + "altitudeAngle : " + Input.GetTouch(i).altitudeAngle);
info += "touch" + i + "altitudeAngle : " + Input.GetTouch(i).altitudeAngle + "\n";
Debug.Log("touch" + i + "azimuthAngle : " + Input.GetTouch(i).azimuthAngle);
info += "touch" + i + "azimuthAngle : " + Input.GetTouch(i).azimuthAngle + "\n";
Debug.Log("touch" + i + "deltaPosition : " + Input.GetTouch(i).deltaPosition);
info += "touch" + i + "deltaPosition : " + Input.GetTouch(i).deltaPosition + "\n";
Debug.Log("touch" + i + "deltaTime : " + Input.GetTouch(i).deltaTime);
info += "touch" + i + "deltaTime : " + Input.GetTouch(i).deltaTime + "\n";
Debug.Log("touch" + i + "fingerId : " + Input.GetTouch(i).fingerId);
info += "touch" + i + "fingerId : " + Input.GetTouch(i).fingerId + "\n";
Debug.Log("touch" + i + "maximumPossiblePressure : " + Input.GetTouch(i).maximumPossiblePressure);
info += "touch" + i + "maximumPossiblePressure : " + Input.GetTouch(i).maximumPossiblePressure + "\n";
Debug.Log("touch" + i + "phase : " + Input.GetTouch(i).phase);
info += "touch" + i + "phase : " + Input.GetTouch(i).phase + "\n";
Debug.Log("touch" + i + "position : " + Input.GetTouch(i).position);
info += "touch" + i + "position : " + Input.GetTouch(i).position + "\n";
Debug.Log("touch" + i + "pressure : " + Input.GetTouch(i).pressure);
info += "touch" + i + "pressure : " + Input.GetTouch(i).pressure + "\n";
Debug.Log("touch" + i + "radius : " + Input.GetTouch(i).radius);
info += "touch" + i + "radius : " + Input.GetTouch(i).radius + "\n";
Debug.Log("touch" + i + "radiusVariance : " + Input.GetTouch(i).radiusVariance);
info += "touch" + i + "radiusVariance : " + Input.GetTouch(i).radiusVariance + "\n";
Debug.Log("touch" + i + "rawPosition : " + Input.GetTouch(i).rawPosition);
info += "touch" + i + "rawPosition : " + Input.GetTouch(i).rawPosition + "\n";
Debug.Log("touch" + i + "tapCount : " + Input.GetTouch(i).tapCount);
info += "touch" + i + "tapCount : " + Input.GetTouch(i).tapCount + "\n";
Debug.Log("touch" + i + "type : " + Input.GetTouch(i).type);
info += "touch" + i + "type : " + Input.GetTouch(i).type + "\n";
}
}
infoText.text = info;
}
}
Android开发 调试环境的更多相关文章
- Win7 32位下cocos2dx android开发调试环境
1.使用环境 win7 32位 + vs2010 2.软件准备(下方绿色文字带链接) cocos2dx-v2.2.2 jdk7 android sdk android ndk adt bundle a ...
- Android开发adb环境配置
adb的全称为Android Debug Bridge,就是起到调试桥的作用. 在命令行cmd中打开adb,如果Android开发的环境配置有误,会出现如下错误提示: 解决方法,右键我的电脑-> ...
- Android开发调试无法连接到夜神模拟器的解决方法
Android开发调试无法连接到夜神模拟器的解决方法: 一般原因是adb的版本不一致造成的!!!!!换成一样的就可以了. 在网上看到的方法,特记录下来: 1.任务管理器里看下,adb.exe以及nox ...
- PHP开发调试环境配置(基于wampserver+Eclipse for PHP Developers )
1 软件准 WampServer 下载地址:http://www.wampserver.com/en/#download-wrapper 我下的是 里面包含了搭建PHP必须的4个软件: 1. ...
- golang在Windows下Sublime Text开发调试环境的配置
一.前言 近期本人有工作调动,进入了一个全新的领域[golang]服务端开发.在此写下本文,希望给那些没接触过golang开发调试环境及还在犹豫选择那家golang IDE而纠结的朋友们一点点帮助,如 ...
- windows下用eclipse+goclipse插件+gdb搭建go语言开发调试环境
windows下用eclipse+goclipse插件+gdb搭建go语言开发调试环境 http://rongmayisheng.com/post/windows%E4%B8%8B%E7%94%A ...
- 配置Windows 2008 R2 64位 Odoo 8.0 源码PyCharm开发调试环境
安装过程中,需要互联网连接下载python依赖库: 1.安装: Windows Server 2008 R2 x64标准版 2.安装: Python 2.7.10 amd64 到C:\Python27 ...
- 在cocos code ide的基础上构建自己的lua开发调试环境
对于一种语言,其所谓开发调试环境, 大体有以下两方面的内容: 1.开发, 即代码编写, 主要是代码提示.补齐, 更高级一点的如变量名颜色等. 2.调试, 主要是运行状态下断点.查看变量.堆栈等. 现在 ...
- 配置Windows 2008 R2 64位 Odoo 8.0/9.0 源码开发调试环境
安装过程中,需要互联网连接下载python依赖库: 1.安装: Windows Server 2008 R2 x64标准版 2.安装: Python 2.7.10 amd64 到C:\Python27 ...
随机推荐
- Newnode's NOI(P?)模拟赛 第三题 (主席树优化建图 + tarjan)
题目/题解戳这里 这道题题目保证a,b,ca,b,ca,b,c各是一个排列-mdzz考场上想到正解但是没看到是排列,相等的情况想了半天-然后写了暴力60分走人- 由于两两间关系一定,那么就是一个竞赛图 ...
- python--UUID唯一标识符
UUID: 通用唯一标识符 ( Universally Unique Identifier ), 对于所有的UUID它可以保证在空间和时间上的唯一性. 它是通过MAC地址, 时间戳, 命名空间, 随机 ...
- Linux安装JAVA web环境
一:安装jdk 1.下载 在oracle下载东西的时候因为oracle的一些验证机制,所以需要在链接前面添加一些参数 wget --no-check-certificate --no-cookie ...
- 【Winform-自定义控件】自定义控件学习+一个笑脸控件例子
1.CompositeControls组合控件:在原有控件的基础上根据需要进行组合 2.ExtendedControls 扩展控件:继承自原有控件,添加一些新的属性和方法,绘制一些新元素 当每个But ...
- ibatis和mybatis中的BatchExecutor
ibatis中的的处理方法 spring集成了ibatis的批量提交的功能,我们只要调用API就可以了 首先在你的dao中需要继承org.springframework.orm.ibatis.supp ...
- AcWing:99. 激光炸弹(前缀和)
一种新型的激光炸弹,可以摧毁一个边长为 RR 的正方形内的所有的目标. 现在地图上有 NN 个目标,用整数Xi,YiXi,Yi表示目标在地图上的位置,每个目标都有一个价值WiWi. 激光炸弹的投放是通 ...
- react搭建项目
1.创建react项目 使用react脚手架create-react-app npm install -g create-react-app create-react-app my-app cd my ...
- 关于hive on spark会话的共享状态
spark sql中有一个类: org.apache.spark.sql.internal.SharedState 它是用来做: 1.元数据地址管理(warehousePath) 2.查询结果缓存管理 ...
- Error:java: 错误: 不支持发行版本 5
本文链接:https://blog.csdn.net/wo541075754/article/details/70154604 在Intellij idea中新建了一个Maven项目,运行时报错如下: ...
- php下intval()和(int)转换使用与区别
没啥区别,一般用(int),另外还有 float, string, array 等 intval()而言,如果参数是字符串,则返回字符串中第一个不是数字的字符之前的数字串所代表的整数值.如果字符串第一 ...