当前位置:网站首页>Unity 入门
Unity 入门
2022-07-27 14:55:00 【CAir2】
下面以网上源码作为学习demo:https://github.com/sensorsdata/sa-sdk-unity/releases/tag/v1.0.2
1. 运行Unity
选中Main Camera,并在Inspector里面设置运行的脚本,选中Sample
运行效果如图:

2. VS 调试 Unity
菜单:Edit->Preferences,此时在工程目录下面就可以看见VS的解决方案

使用VS打开之后就能看见C#脚本,此时就可以附加到Unity进行调试了。
附加Unity就绪之后,就可以运行Unity,然后就行调试了。
3. 切换Unity运行平台(ios,android,pc)
File->Build Settings

如果是android设备的话,请将Edit- >Project Settings->Editor 里面的Device设置 Any
4. 导出android 工程或者编译apk
File->Build Settings
如果勾选Export Project,则会到处android工程,此时编译android生成apk
如果不勾选Export Project,则直接生成apk
在实战过程中,我直接生成apk始终报错,最终没办法导出android工程,之后编译apk
或者直接编译运行:File->Build and Run

> **踩坑集**
**1. VS调试的时候断点无效**
原因1:源码不匹配,重新生成一下VS工程代码:Regenerate project files。
原因2:平台不匹配。例如调试的android平台代码,运行在pc平台,切换一下运行平台。
**2. unity调试的时候android层的代码始终无效,但是直接运行没问题。最常见的是currentActivity为null**
网上说是使用Unity remote调试,但是我试过N多次,都无效,最终只能打包成apk,通过输出日志来定位分析问题。
边栏推荐
- Apache
- ES6数组的方法及伪数组转数组方法
- 从零开始Blazor Server(1)--项目搭建
- codis集群部署
- AS更换背景主题以及背景图片
- Enumeration and union of C language
- Flex弹性盒布局2
- Program environment and preprocessing of C language
- 京东张政:内容理解在广告场景下的实践和探索
- Handling of multiple parts with duplicate names and missing parts when importing SOLIDWORK assemblies into Adams
猜你喜欢

自然排序:comparable接口,定制排序:compartor接口的区别

牛客题目——对称的二叉树

Layoff quarrel, musk: I'm too hard; Mercilessly open source a public opinion acquisition project; Feature engineering is as simple as parameter adjustment?! Nerf boss shouted that he couldn't move; Cu

As changes the background theme and background picture

实测:云RDS MySQL性能是自建的1.6倍
Interpretation of C basic syntax: summarize some commonly used but easily confused functions (i++ and ++i) in the program (bit field)

什么是jsp?

2021 national vocational college skills competition (secondary vocational group) network security competition questions (9) ideas
The difference between MVC and MVP and MVVM

C语言之文件操作
随机推荐
OpenCV(三)——图像分割
分享一个网上搜不到的「Redis」实现「聊天回合制」的方案
Matlab legend usage
Array analog linked list
MPC5744p时钟模块
ES6数组新增属性
Mpc5744p clock module
Handling of multiple parts with duplicate names and missing parts when importing SOLIDWORK assemblies into Adams
codis集群部署
LNMP environment - deploy WordPress
json数据解析
Niuke topic -- judge whether it is a complete binary tree or a balanced binary tree
Casadi -- detailed explanation of data types and introduction to basic operations
Dynamic memory allocation in C language
Interpretation of C basic syntax: summarize some commonly used but easily confused functions (i++ and ++i) in the program (bit field)
MQ Series 2: technology selection of Message Oriented Middleware
合工大苍穹战队视觉组培训Day8——视觉,目标识别
jsp-El表达式,JSTL标签
实测:云RDS MySQL性能是自建的1.6倍
C语言之枚举和联合体