先做简单的好了
**
Creating UI Buttons
**
Buttons are one of the most commonly used UI components. They are very easy to customize and quick to configure to complement any art style to match an application. In this tutorial, you will learn to create UI buttons.
complement补足
这不是之前学过了吗。略
**
Creating a Screen Space Overlay UI
**
以前学到过的世界UI和屏幕UI
overlay覆盖
Unity features several different types of User Interface options that allow users to create UI that precisely fit their application’s needs. There are two main types of UI categories: Screen Space and World Space. In this tutorial, you will learn to create a Screen Space UI.
Unity提供了几种不同类型的用户界面选项,允许用户创建精确满足其应用程序需求的UI。
constant常数, cut off切断 scaled in按比例放大 resolution分辨率 proportion比例 evenly均匀的
**
Grouping and Layout Techniques for UI Components
**
Unity’s UI system is flexible enough for nearly any imaginable purpose. Sometimes, there are situations where we don’t know ahead of time what we’ll need to display, but rather what we have room for. In this tutorial, you will learn to create an inventory that uses different Layout Groups to arrange your UI elements.
可能不知道要布置什么样的UI,然后用Inventory(库存),看下面脚本就知道了
另,想要复习做一遍就行,不看做一遍
这就是库存和背包系统吗?role-playing game里的仓库???
提示,现在2020版小书变成小问号了,点击它前往手册
the padding inside the edges of the layout group布局组边缘内的填充
inventory库存 impractical不切实际的
assemble装配集合 child alignment子级对齐?
就是把这个InventoryDisplayControl拖到这个Convas里面,再把这个新建的叫ShowAllItemsButton的拖到它下面。。
像素填充在任一维度和额外的空间为面板边界。? overlap重叠
另外,是我就先把东西创建好然后才写脚本
总之这些东西,自己调一下就可以知道是干嘛的了
这里left=8,会让最左边长8,中间每个间隔12,然后因为总宽676,所以刚好最右边也8,上下同理
总之自己调一调就知道了
constraint约束
demonstration 示范
在布局组中嵌套UI元素是自动化布局和处理各种情况的一种有效方法,与其他情况相比,代码和手动工作量要少得多。
实践过程中出现蜜汁bug,脚本不能给物体,正在新建新的project,果然好了,不同版本之间看来不要直接用
另外做完之后才发现就是游戏中常有的整理背包给物品分类的东西!
值得注意的是,最后的结果就是需求:,分清功能提供者和调用者,
panel提供功能:显示所有的按钮或者显示某一类,因为所有物品按钮放在panel下统一按格式排列好了,,每个物品按钮提供功能:为自己随机赋值,并提供一个public随机数,panel的方法利用这个数来判断。
方法调用者为另外的放在名为InventoryDisplayControl的空物体的四个按钮上,通过event调用panel的脚本并通过给定参数区分不同
**
Introduction to Optimization in Unity
**
Unity’s optimization tools allow you to diagnose common performance problems and refine a project’s design, code, and related assets to maximize efficiency. An optimized project will run smoother and more responsively on your target platforms and devices. This tutorial will help you better understand optimization tools and techniques available in Unity and provides suggested uses for each tool.
To learn how to use each tool, please refer to the following tutorials: Working with the Profiler Window, Working with the Stats Window, Working with the Frame Debugger, and Optimization Approaches for Project Assets.
diagnose 诊断 profiler轮廓仪 , 而profiler window是 配置文件窗口
好多。一个一个来喽
**Working with the Profiler Window **
The Profiler window is an incredibly powerful tool that provides detailed information on how your project is performing. During runtime, it details your project’s Central Processing Unit (CPU) usage, memory, physics, network usage and more. In this tutorial, you will learn about the Profiler window and its uses.
window - analysis - profiler
通过这个神奇的东西可以监测什么占用cpu多来找到去优化哪里
If your project is experiencing problems , such as low framerate(帧速率) or high memory usage, the Profiler can show you what causing these problems and help you plan how to fix them.
后面都介绍一些简单的东西,没什么好记的。
Working with the Stats Window
Inside the Game window, there’s a Stats button in the top right corner. When this button is pressed, an overlay(覆盖) window appears. This window shows real-time rendering statistics(统计学), which is incredibly useful for optimizing performance(优化性能). In this tutorial, you will learn about the Stats window and its uses.
decibel分贝 audio distortion音频失真 數位信號處理器(英語:digital signal processor ,DSP)
overhead开销 triangle drawn三角形绘制。。 anti-aliasing抗锯齿 shadow casting阴影投射
另外:pinpoint准确指出
Working with the Frame Debugger
The Frame Debugger is a handy tool that allows you to freeze playback(回放) for a running game on a particular frame to view the individual draw calls used to render that frame. The debugger also lets you go through frames one-by-one so you can see in greater detail how the scene is constructed. In this tutorial, you will learn about the Frame Debugger and how to use it for analysis.
Draw Call就是CPU调用图形编程接口,比如DirectX或OpenGL,来命令GPU进行渲染的操作。
例如,DirectX中的DrawIndexedPrimitive命令,OpenGL中的glDrawElement命令。
1.CPU和GPU并行工作的原理为了CPU和GPU可以并行工作,就需要一个命令缓冲区(Command Buffer)命令缓冲区包含了一个命令队列,由CPU向其中添加命令,而由GPU从中读取命令。添加和读取的过程是相互独立的,因此命令缓冲区可以使CPU和GPU相互独立工作。当CPU需要渲染一些对象时,它可以向命令缓冲区添加命令,而GPU完成了上一次的渲染任务后,它就可以从命令队列里取出一个命令并执行它。命令缓冲区中的命令有很多种类,而Draw Call是其中的一种,其它命令还有改变渲染状态等命令(改变使用的Shader,使用不同的纹理等)。
2.为什么 Draw Call多了会影响帧率?在每次调用Draw Call之前,CPU需要向GPU发送很多内容,包括数据,状态,命令等。在这一阶段,CPU需要完成很多工作,例如检查渲染状态等。而一旦CPU完成了这些准备工作,GPU就可以开始本次的渲染。GPU的渲染能力是很强的,渲染300个和3000个三角网格通常没有什么区别,因此渲染速度往往快于CPU提交命令的速度。如果Draw Call的数量太多,CPU就会把大量时间花费在提交Draw Call命令上,造成CPU的过载。*因此造成Draw Call性能问题的元凶是CPU。
3.如何减少DrawCall?提交大量很小的Draw Call会造成CPU的性能瓶颈,即CPU把时间都花费在准备Draw Call的工作上了。那么,一个很显然的优化想法就是把很多小的Draw Call合并成一个大的Draw Call,这就是批处理的思想。需要注意的是,由于我们需要在CPU的内存中合并网格,而合并的过程是需要消耗时间的。因此,批处理更适合静态的物体,例如不会移动的大地,石头等,对于这些静态物体我们只需合并一次即可。当然,我们也可以对动态物体进行批处理。但是,由于这些物体是不断运动的,因此每一帧都需要重新进行合并然后再发送给GPU,这对空间和时间都会造成一定的影响。
作者:SwordMaster003
链接:https://www.jianshu.com/p/061b84e4f863
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
window - analysis - frame debugger
下一部分
这里的每一个小部分都可以细说好多。。
Batch批 potential潜在的
memory handling内存处理 heap堆,stack栈 lunch tray午餐托盘。。 aside from除了 allocate分配拨给
栈中限制存放暂时的和小的变量,声明变量的时候会内存从栈中分配,,
contiguous相邻的 insufficient不足的 hiccup打嗝
栈中的内存会被自动释放当没有引用时,
堆里放更大或存放更久的变量,同时访问速度变慢
当使用new关键字来创建object的时候,在堆中分配内存,(类是引用类型时,自然要用new来创建对象
在堆中的变量要占据一个连续的相邻的块,
原来垃圾只有在堆里,栈的会自动释放,而堆中不需要继续存放变量数据的内存叫垃圾,释放这些内存叫垃圾收集,通常在需要时发生,但也可以手动触发,取决于释放内存的量,可能造成性能打嗝。。
对象池。。应用于会频繁创建销毁的,比如子弹,枪口火花,procedurally generated destructible terrian程序生成的可破坏区域
scenario脚本 pooled汇集 introduce performance issue引入性能问题。。想想看,在游戏里突然一次性大量刷新怪物,或特效的时候确实会卡。。分配内存和实例化物体的过程是慢的
第二段看不懂
另外,Optimization Approaches for Project Assets(项目资产的优化方法) 在这个project的最后一个教程
caching缓存,暂时存储,很快!metaphor隐喻,类似于便利签一样的东西?需要频繁访问的就缓存
这里的例子中update就是频繁访问吧,那么在start或awake中getcomponent原来是取组件取到了缓存里?
虽然很想去查查手册,但是想想就头大,还是算了,赶紧速速结束这部分,
good practice好的做法 consistency一致性
update没有以稳定的间隔运行,而是依赖帧速率,不一致性会导致物理模仿的问题,所以物理的最好放在fixed里
lateUpdate没懂。。
introduce lag引用滞后 encase in a conditional block封装在条件块中 但是这里说的不是很显然的事吗。。
协程。。
wave shooter game。。顺便这里说超过帧的间隔的话将方法放到Start里用InvokeRepeating()
代码原来就这么糊,但是勉强也能看得清楚,
iteration迭代 declutter整理 interfere干涉 corporate公司 incorporate合并
建议是不要在开始的时候就纠结优化的事
还剩下两个,加上上次那个,也太tm长了,,有空在看吧,先学后面的。。