UIRect中的Anchor组件

UIRect中的Anchor组件

  Anchor用于实现粘着功能,寄存于UIRect类中。Anchor的类型有三种:

    1、None:不使用跟随功能。

    2、Unified:四条边使用相同的Target。

    3、Advanced:四条边分别拥有各自的Target。

  在Anchor的系统中,一个Rect被拆分为四条边,left、right、top、bottom。right-left=width、bottom-top=heigth。设置四条边,则UIWidget中的宽高会自动改变,反之亦然。

  Unified Anchor截图如下:

  

  当使用Anchor时,本类的pivot与父结点的pivot重合。每条边的跟随类型有4种:

    1、Target's Left:以Target的左边为基准。

    2、Target's Center:以Target的中点为基准。

    3、Target's Right:以Target的右边为基准。

    4、Custom:以Target总宽度(长度)的百分比偏移为基准。

  所以Anchor是一个很牛X的,可以帮助我们轻松实现各类跟随功能的组件。

UIAnchor

  UIAnchor是NGUI抛弃的技术,如上所述,新的NGUI中UIRect中包括了Anchor组件。

  

  • Half Pixel Offset can make the anchor apply a half-pixel offset to its position on Windows machines to account for theDirectX 9 bug. Should be checked for 2D UI.
  • UI Camera is the camera used to draw this object. It’s chosen automatically unless set manually.

参考:

1、http://www.tasharen.com/forum/index.php?topic=7013

原文地址:https://www.cnblogs.com/tekkaman/p/3804634.html