当前位置:网站首页>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,通过输出日志来定位分析问题。
边栏推荐
- The class declared by the scala object keyword directly calls methods and associated objects
- Servlet用Cookie实现用户上次登录时间
- Codeforces Round #100 E. New Year Garland & 2021 CCPC Subpermutation
- Duplicate names in molecular class methods
- Build a cloud native file system for media assets
- Measured: the performance of cloud RDS MySQL is 1.6 times that of self built
- Niuke topic -- Realizing queues with two stacks, stacks containing min functions, and valid bracket sequences
- File operation in C language
- C语言之分支循环语句
- Niuke topic -- symmetric binary tree
猜你喜欢

Flex弹性盒布局

Niuke topic -- symmetric binary tree

OpenCV(三)——图像分割

Getting started with nvida CUDA dirverapi

(2) Dynamic convolution of dynamic convolution

Apache

合工大苍穹战队视觉组培训Day7——视觉,jetson naon与D435i

【pytorch】|transforms.FiveCrop

Life game, universe 25 and striver

Measured: the performance of cloud RDS MySQL is 1.6 times that of self built
随机推荐
log4j.jar和slf4-log4下载链接
JDBC连接数据库
牛客题目——二叉搜索树与双向链表
String numeric type converted to thousands
Program environment and preprocessing of C language
Life game, universe 25 and striver
Ten thousand words analysis ribbon core components and operation principle
Niuke topic -- binary search tree and bidirectional linked list
合工大苍穹战队视觉组培训Day8——视觉,目标识别
ShardingSphere-proxy-5.0.0分布式雪花ID生成(三)
meta-data 占位符的引用
CODIS cluster deployment
mvc和mvp和mvvm的区别
内置对象(下)
Jerry's built-in touch parameters for modification [chapter]
Embedded interview
Niuke topic - parity rearrangement of linked list, right view of output binary tree, bracket generation, first non repeating character in character stream
Interpretation of C basic syntax: summarize some commonly used but easily confused functions (i++ and ++i) in the program (bit field)
Leader: who uses redis overdue monitoring to close orders and get out of here!
Jerry's in ear detection function [chapter]