namespace EasyLayoutNS { using System.Collections.Generic; using UnityEngine; /// /// EasyLayout utilities. /// public static class EasyLayoutUtilities { /// /// Convert list to string. /// /// Value type. /// Values. /// String. public static string List2String(List values) { var sb = new System.Text.StringBuilder(); for (int i = 0; i < values.Count; i++) { var v = values[i]; if (i == 0) { sb.Append(v.ToString()); } else { sb.Append("; "); sb.Append(v.ToString()); } } return sb.ToString(); } /// /// Convert list to string. /// /// Value type. /// Values. /// String. public static string List2String(T[] values) { var sb = new System.Text.StringBuilder(); for (int i = 0; i < values.Length; i++) { var v = values[i]; if (i == 0) { sb.Append(v.ToString()); } else { sb.Append("; "); sb.Append(v.ToString()); } } return sb.ToString(); } /// /// Maximum count of items in group. /// /// Type of item. /// Group. /// Maximum count. public static int MaxCount(List> group) { int result = 0; for (int i = 0; i < group.Count; i++) { result = Mathf.Max(result, group[i].Count); } return result; } /// /// Transpose the specified group. /// /// Group. /// The 1st type parameter. /// Transposed list. public static List> Transpose(List> group) { var result = new List>(); for (int i = 0; i < group.Count; i++) { for (int j = 0; j < group[i].Count; j++) { if (result.Count <= j) { result.Add(new List()); } result[j].Add(group[i][j]); } } return result; } /// /// Get scaled width. /// /// The width. /// User interface. public static float ScaledWidth(RectTransform ui) { return ui.rect.width * ui.localScale.x; } /// /// Get scaled height. /// /// The height. /// User interface. public static float ScaledHeight(RectTransform ui) { return ui.rect.height * ui.localScale.y; } } }