public void Add(int index, RectTransform content) { CustomLayout customLayout = Instantiate(m_Prefab, LayoutGroup.transform).GetComponent <CustomLayout>(); customLayout.transform.SetSiblingIndex(index); if (LayoutGroup is HorizontalLayoutGroup) { customLayout.Set(Layout.Vertical); } else { customLayout.Set(Layout.Horizontal); } content.SetParent(customLayout.ContentRectTransform); DropZoneRectTransform.SetAsLastSibling(); }
private CustomLayout CheckParent() { CustomLayout parentLayout = transform.parent.GetComponent <CustomLayout>(); if (parentLayout == null) { parentLayout = Instantiate(m_Prefab, transform.parent).GetComponent <CustomLayout>(); parentLayout.transform.SetSiblingIndex(transform.GetSiblingIndex()); if (LayoutGroup is HorizontalLayoutGroup) { parentLayout.Set(Layout.Vertical); } else { parentLayout.Set(Layout.Horizontal); } transform.SetParent(parentLayout.LayoutGroup.transform); } return(parentLayout); }