Example #1
0
        // TODO: Move this to UI classes
        public GameObject BuildGUI(GameObject parent)
        {
            m_Root = new GameObject(string.Format("{0}", m_Name));
            m_Root.transform.SetParent(parent.transform);
            m_Root.transform.localPosition = Vector3.zero;
            m_Root.transform.localScale    = Vector3.one;

            UI.VerticalLayoutGroup menuVL = m_Root.AddComponent <UI.VerticalLayoutGroup>();
            menuVL.spacing                = 5.0f;
            menuVL.childControlWidth      = true;
            menuVL.childControlHeight     = true;
            menuVL.childForceExpandWidth  = true;
            menuVL.childForceExpandHeight = false;

            RectTransform menuVLRectTransform = m_Root.GetComponent <RectTransform>();

            menuVLRectTransform.pivot         = new Vector2(0.0f, 0.0f);
            menuVLRectTransform.localPosition = new Vector3(0.0f, 0.0f);
            menuVLRectTransform.anchorMin     = new Vector2(0.0f, 0.0f);
            menuVLRectTransform.anchorMax     = new Vector2(1.0f, 1.0f);

            RebuildGUI();

            m_Root.SetActive(false);
            return(m_Root);
        }
Example #2
0
        public static GameObject CreateVerticalLayoutGroup(string name, bool controlWidth, bool controlHeight, bool forceExpandWidth, bool forceExpandHeight, float spacing, GameObject parent = null)
        {
            GameObject go = new GameObject(name);

            go.transform.SetParent(parent.transform, false);
            UI.VerticalLayoutGroup verticalLayout = go.AddComponent <UI.VerticalLayoutGroup>();
            verticalLayout.childControlHeight     = controlHeight;
            verticalLayout.childControlWidth      = controlWidth;
            verticalLayout.childForceExpandHeight = forceExpandHeight;
            verticalLayout.childForceExpandWidth  = forceExpandWidth;
            verticalLayout.spacing = spacing;

            return(go);
        }