周笔记(20/52)

来源:互联网 发布:手机淘宝图片最佳尺寸 编辑:程序博客网 时间:2024/05/21 13:07

于是乎这一篇编程Unity学习过程中的小知识点集锦了~

问题列表

UI

  1. 如何使用Material?RichText的quad图片根据material指定的吗?
  2. 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

  1. RectTransform:在每帧结束、计算UI Vertices前计算改变。第一次Start和Update时未经计算。可使用Canvas.ForceUpdateCanvases()来强行刷新。
  2. Canvas:
    1. Aspect ratio filter:Width Controll Height
  3. Animator:改变例如Button的Translation
  4. Auto Layout(适配):
    1. 改变:driven properties、LayoutRebuilder.MarkLayoutForRebuild
    2. 不要再在inspector里重设被驱动的数值
    3. 继承 ILayoutElement/ILayoutGroup/ILayoutSelfController 以自定义
    4. 先考虑width后考虑height:从子到父计算大小 -> 从父到子设置大小
  5. RichText
    1. Debug.Log里也可以用RichText来更炫酷的打印
    2. 用material来指定材质列表里的材质
    3. 用quad在行内插入图片

Camera

  1. 第二摄像机:
    1. GetComponent().pixelRect = new Rect(hloc,vloc,hsize,vsize);
  2. 切换摄像机:
    1. GetComponen().enabled = cameraActive;
    2. GetComponent().enabled = cameraActive;
  3. 截屏:
    1. photoGUI.SetActive (false);
    2. Texture2D texture = new Texture2D(textWidth,textHeight);
    3. yield return new WaitForEndOfFrame();
    4. texture.ReadPixels(IRect)framing, 0, 0);
    5. texture.Apply();
    6. photoGUI.SetActive (true);
  4. 保存图片
    1. Texture2D.EncodeToPNG

Shader

(换用xmind记这一块。。)

原创粉丝点击