奥东......NGUI Example1- Anchors

参考文章:

            http://dsqiu.iteye.com/blog/1975972(有些古老了,但是内容还是有可取之处)

Anchor的版本更新历史:

                                 发现NGUI3.6.4b 版本中的Example 1-Anchors中竟然没有发现在GameObject中有UIAchors脚本,所以参考DSQiu(上述链接)就没有办法吸收了,所以只有自己Look Look

                                 UIAnchor Script 官网说,要废弃,所以我就看看历史版本中的变动,看看Anchor在历史中有什么变化

                                 3.6.4:    - FIX:  Nested anchors set to update in OnEnable will now work as expected when the hierarchy gets re-enabled.

            3.6.1:- NEW:  EnvelopContent script will now execute itself every time it's enabled, and will update anchors.

            3.5.6:  - FIX:  Anchors set to update only in OnEnable will now still update while in edit mode.

            3.5.5:  - NEW: Widget anchors now have an option to be executed only when enabled, rather than every update. 这里是个重点变动,很多继承了widget anchors的东东,都会有一个Option

                 3.2.3 (previously 3.0.7 f3)  - NEW: Added an option for anchors to be offset by the panel's position.

            3.2.2 (previously 3.0.7 f2)

                          - FIX: Non-clipped panels will no longer use their position when calculating dimensions for anchors.
                          - FIX: Panels can now use advanced anchors properly (partial anchoring).

分析官方案例:

        

                      

                      

                      Window是一个空GameObject,Window Border,Stripes是一个Sprite

                      Window Border作为Anchors的Target选项,就是作为了Text,和Stripes中的Target,这里其实一个Text(间距是30)的Panel就可以了,但是为了好看,加上了一个Stripes(间距是12),美观方面可以借鉴下(如上图两个红箭头所示)

本项目中的Depth集合:

Stretched Background Depth:-10

Window Border           Depth: -5

Stripes        Depth: -4

Text          Depth: -1

UIRoot        Depth:  0

Camera                     Depth:  1

Button(八个按钮)         Depth:  2

按钮 中的Label      Depth: 3

                      

 Pre Tip 1:

  Anchors中Execute类型选项的时候一般要选中OnEnable类型,这样的话,相对于OnUpdate()效率会高一些

Pre Tip 2 :

 Anchors中的Left,Right,Bottom,Top选项中,不是Left选项中对应的就是Target's Left,而是由多种选项,还可以自己定义(Customer选项)

 创建场景的时候删除新建的场景的Main Camera摄像机,在图层中新建一个GUI层,接着,选择菜单上的NGUI->Create a new UI

posted @ 2014-10-31 14:03  奥东  阅读(169)  评论(0)    收藏  举报