Play with Unity 4.6. The most annoying thing is layout system.
- I can’t disable it if i would like to.
- I can’t make my widget to have absolute left offset and relative right offset(without extra game objects).
When i working on layout system for my project i think a lot about how to implement it. And what i got now:
LayoutObject - component that contains information about size of the object(also min/max limits of the object), padding, and references to left/top/right/bottom anchors.
LayoutAnchor - component that have type(enum {Left, Right, Top, Bottom, MiddleVertical, MiddleHorizontal}), value(offset) and valueMode(enum {absolute, relative}) + methods to calculate is final position and list of objects to notify when parent layoutObject change size or position.
When LayoutObject change size or position its notify all LayoutObjects that is linked to its anchors. Many LayoutObjects can be linked to one anchor and its doesn’t know about context where its appear. Its right to do so because child GUI element should’t know about how they should behave inside parent element, only parent GUI element can change layout by changing anchor values. And i think its SOLID way to layout.
In Unity 4.6 i can bind many elements to one “anchor” but i have to create some extra GameObject(+1 GameObject, +1 RectTransform with lot of properties) that will increase runtime overhead, asset size, and loading time…