The problem
Currently layout is designed the way that controllers are responsible for layout application. This approach allows the system to be simple, but disables a lot of capabilities.
The solution
Shift the responsibility by making ILayoutItem accept the dimensions instead of exposing the entire RectTransform instance.
Current variant:
public interface ILayoutItem : ILayoutRecalculationSource {
//...
RectTransform BeginApply();
void EndApply();
}
Replace with:
struct LayoutDimensions {
public float TopOffset;
public float LeftOffset;
public float Width;
public float Height;
}
public interface ILayoutItem : ILayoutRecalculationSource {
//...
void Apply(LayoutDimensions dimensions);
}
This approach enables us to implement an intermediate layer for animations, allowing lerping between states without knowing the exact values.
The problem
Currently layout is designed the way that controllers are responsible for layout application. This approach allows the system to be simple, but disables a lot of capabilities.
The solution
Shift the responsibility by making
ILayoutItemaccept the dimensions instead of exposing the entireRectTransforminstance.Current variant:
Replace with:
This approach enables us to implement an intermediate layer for animations, allowing lerping between states without knowing the exact values.