private static void InitializeNewObject(Transform parent, int siblingIndex, UIContainer container, UIObject obj, UIDir dir) { GameObject item = obj.gameObject; item.SetActive(true); item.transform.SetParent(parent); item.transform.SetSiblingIndex(siblingIndex); item.transform.localScale = new Vector3(1, 1, 1); //UT.print("Init. size: " + obj.GetWidth() + ", " + obj.GetHeight()); container.Add(obj, dir); // add new item after previous to 'dir' direction. if (container.anchor == UIAlign.CENTER) { Vector2 offset = new Vector2(-container.GetWidth() / 2f, container.GetHeight() / 2f); container.SetScreenPosition(getScreenPosition(0, 0) + offset); } else if (container.anchor == UIAlign.TOP_LEFT) { container.SetScreenPosition(getScreenPosition(-.5f, .5f)); } else if (container.anchor == UIAlign.LEFT) { container.SetScreenPosition(getScreenPosition(-.5f, 0f)); } else if (container.anchor == UIAlign.BOTTOM_LEFT) { Vector2 offset = new Vector2(0f, container.GetHeight()); container.SetScreenPosition(getScreenPosition(-.5f, -.5f) + offset); } else { UT.trap("AMenu.InitializeButton: invalid orientation."); } }