Allowed flexible row expansion as a choice, instead of a compulsion
--HG-- branch : develop_5.3pull/413/head
parent
da480b1f8b
commit
9cf482d6ed
|
@ -58,6 +58,20 @@ namespace UnityEngine.UI.Extensions
|
|||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
protected bool flexibleRowHeight = true;
|
||||
/// <summary>
|
||||
/// Expand rows to fit the cell with the highest preferred height?
|
||||
/// </summary>
|
||||
public bool FlexibleRowHeight
|
||||
{
|
||||
get { return flexibleRowHeight; }
|
||||
set
|
||||
{
|
||||
SetProperty(ref flexibleRowHeight, value);
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
protected float cellSpacing = 0f;
|
||||
/// <summary>
|
||||
|
@ -122,6 +136,8 @@ namespace UnityEngine.UI.Extensions
|
|||
totalPreferredHeight += heightFromSpacing;
|
||||
}
|
||||
|
||||
if (flexibleRowHeight)
|
||||
{
|
||||
// Find the max value for minimum and preferred heights in each row
|
||||
for (int i = 0; i < rowCount; i++)
|
||||
{
|
||||
|
@ -146,6 +162,17 @@ namespace UnityEngine.UI.Extensions
|
|||
maxPreferredHeightInRows[i] = maxPreferredHeightInRow;
|
||||
totalPreferredHeight += maxPreferredHeightInRow;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < rowCount; i++)
|
||||
{
|
||||
maxPreferredHeightInRows[i] = minimumRowHeight;
|
||||
}
|
||||
|
||||
totalMinHeight += rowCount * minimumRowHeight;
|
||||
totalPreferredHeight = totalMinHeight;
|
||||
}
|
||||
|
||||
totalPreferredHeight = Mathf.Max(totalMinHeight, totalPreferredHeight);
|
||||
SetLayoutInputForAxis(totalMinHeight, totalPreferredHeight, 1, 1);
|
||||
|
|
Loading…
Reference in New Issue