/// <summary> /// Is target width under layout group or fitter control? /// </summary> /// <param name="target">Target.</param> /// <returns>true if target width under layout group or fitter control; otherwise false.</returns> public static bool IsWidthControlled(RectTransform target) { var ignorer = Compatibility.GetComponent <ILayoutIgnorer>(target); if (ignorer != null && ignorer.ignoreLayout) { return(false); } var fitter = target.GetComponent <ContentSizeFitter>(); if ((fitter != null) && (fitter.horizontalFit != ContentSizeFitter.FitMode.Unconstrained)) { return(true); } var parent = target.transform.parent as RectTransform; if (parent != null) { var layout_group = parent.GetComponent <LayoutGroup>(); if (layout_group == null) { return(false); } var g_layout_group = layout_group as GridLayoutGroup; if ((g_layout_group != null) && g_layout_group.enabled) { return(true); } var hv_layout_group = layout_group as HorizontalOrVerticalLayoutGroup; if ((hv_layout_group != null) && hv_layout_group.enabled) { return(Compatibility.GetLayoutChildControlWidth(hv_layout_group)); } var e_layout_group = layout_group as EasyLayout; if ((e_layout_group != null) && e_layout_group.enabled) { return(e_layout_group.ChildrenWidth != ChildrenSize.DoNothing); } } return(false); }