于是乎这一篇编程Unity学习过程中的小知识点集锦了~
问题列表
UI
- 如何使用Material?RichText的quad图片根据material指定的吗?
- Position as UV1有什么用?看上去貌似是用来写shader的?
(It passes the canvas position through to the first UV channel. This can be used for things like refraction or UV offset sampling in a custom shader.)
笔记
UI
- RectTransform:在每帧结束、计算UI Vertices前计算改变。第一次Start和Update时未经计算。可使用Canvas.ForceUpdateCanvases()来强行刷新。
- Canvas:
- Aspect ratio filter:Width Controll Height
- Animator:改变例如Button的Translation
- Auto Layout(适配):
- 改变:driven properties、LayoutRebuilder.MarkLayoutForRebuild
- 不要再在inspector里重设被驱动的数值
- 继承 ILayoutElement/ILayoutGroup/ILayoutSelfController 以自定义
- 先考虑width后考虑height:从子到父计算大小 -> 从父到子设置大小
- RichText
- Debug.Log里也可以用RichText来更炫酷的打印
- 用material来指定材质列表里的材质
- 用quad在行内插入图片
Camera
- 第二摄像机:
- GetComponent().pixelRect = new Rect(hloc,vloc,hsize,vsize);
- 切换摄像机:
- GetComponen().enabled = cameraActive;
- GetComponent().enabled = cameraActive;
- 截屏:
- photoGUI.SetActive (false);
- Texture2D texture = new Texture2D(textWidth,textHeight);
- yield return new WaitForEndOfFrame();
- texture.ReadPixels(IRect)framing, 0, 0);
- texture.Apply();
- photoGUI.SetActive (true);
- 保存图片
- Texture2D.EncodeToPNG
Shader
(换用xmind记这一块。。)