コード例 #1
0
    void InitMenuList()
    {
        mMenuList.Items.Clear();

        UIMenuListItem parent = null;

        for (int i = 0; i < mInfoList.Count; i++)
        {
            if (mInfoList[i].mParentFalg == MenuItemFlag.Flag_Null)
            {
                parent = null;
            }
            else
            {
                parent = mMenuList.Items.Find(
                    delegate(UIMenuListItem li)
                {
                    return(li.mMenuItemFlag == mInfoList[i].mParentFalg);
                });
            }

            UIMenuListItem item = mMenuList.AddItem(parent, mInfoList[i].mItemText, mInfoList[i].mFlag, mInfoList[i].mItemIcoStr);
            item.KeyId     = mInfoList[i].mKeyId;
            item.mCategory = mInfoList[i].mKeyCategory;
        }

        int menuListPos_y = Convert.ToInt32(mMenuList.rootPanel.spBg.transform.localScale.y / 2) + 26;

        mMenuListPos = new Vector3(-130, menuListPos_y, 0);
        mMenuList.transform.localPosition = mMenuListPos;

        TweenPosition tp = mMenuList.GetComponent <TweenPosition>();

        tp.from = mMenuListPos;

        IsInitMenuList = true;
    }
コード例 #2
0
    public override void OnInspectorGUI_Propertys()
    {
        // ----------------------------------Contents--------------------------------------------------------
        DrawPartLine("Contents");

        GameObject ItemPrefab = EditorGUILayout.ObjectField("UIMeunItemPrefab", menuList.UIMeunItemPrefab, typeof(GameObject), true, GUILayout.ExpandWidth(true)) as GameObject;

        if (ItemPrefab != menuList.UIMeunItemPrefab)
        {
            menuList.UIMeunItemPrefab = ItemPrefab;
        }
        UISlicedSprite SlicedSpriteBg = EditorGUILayout.ObjectField("SlicedSpriteBg", menuList.SlicedSpriteBg, typeof(UISlicedSprite), true, GUILayout.ExpandWidth(true)) as UISlicedSprite;

        if (SlicedSpriteBg != menuList.SlicedSpriteBg)
        {
            menuList.SlicedSpriteBg = SlicedSpriteBg;
        }

        GameObject ItemsContent = EditorGUILayout.ObjectField("ItemsContent", menuList.ItemsContent, typeof(GameObject), true, GUILayout.ExpandWidth(true)) as GameObject;

        if (ItemsContent != menuList.ItemsContent)
        {
            menuList.ItemsContent = ItemsContent;
        }
        GUILayout.Space(2);
        Vector4 margin = EditorGUILayout.Vector4Field("Margin", menuList.Margin);

        if (margin != menuList.Margin)
        {
            menuList.Margin = margin;
            menuList.UpdatePanelPositon();
        }
        GUILayout.Space(7);

        UIMenuPanel root = EditorGUILayout.ObjectField("rootPanel", menuList.rootPanel, typeof(UIMenuPanel), false, GUILayout.ExpandWidth(true)) as UIMenuPanel;

        if (root != menuList.rootPanel)
        {
            menuList.rootPanel = root;
        }

        // ----------------------------------items--------------------------------------------------------
        DrawPartLine("Items");
        GUILayout.Space(2);

        Vector2 v2 = EditorGUILayout.Vector2Field("Item Size", menuList.ItemSize);

        if (v2 != menuList.ItemSize)
        {
            menuList.ItemSize = v2;
            menuList.UpdatePanelPositon();
        }
        GUILayout.Space(2);

        Vector2 panelMargin = EditorGUILayout.Vector2Field("Panel Margin", menuList.PanelMargin);

        if (panelMargin != menuList.PanelMargin)
        {
            menuList.PanelMargin = panelMargin;
            menuList.UpdatePanelPositon();
        }


        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Add Item (Input a item text)");
        string strText = EditorGUILayout.TextField("");

        GUI.backgroundColor = Color.green;
        if (GUILayout.Button(insertContent, min_buttonWidth, min_buttonHeight))
        {
            if (strText.Length == 0)
            {
                strText = "item_" + menuList.Items.Count.ToString();
            }
            menuList.AddItem(null, strText, UIGameMenuCtrl.MenuItemFlag.Flag_Null);
        }
        EditorGUILayout.EndHorizontal();



        for (int i = 0; i < menuList.panels.Count; i++)
        {
            string name = (menuList.panels[i].parent == null) ? " root" : " " + menuList.panels[i].parent.Text;
            DrawPartLine(name);
            DrawMenuPanel(menuList.panels[i].parent);
        }
    }