Exemplo n.º 1
0
 private static string GetLayerName(EAtlasLayers eLayer)
 {
     if (eLayer == EAtlasLayers.Common_1)
     {
         return("0~99:common_1(" + COMMON_1 + ")");
     }
     else if (eLayer == EAtlasLayers.Depth199)
     {
         return("100~199:当前界面图集(" + UIATLAS_NAME + ")");
     }
     else if (eLayer == EAtlasLayers.Common_2)
     {
         return("200~299:common_2(" + COMMON_2 + ")");
     }
     else if (eLayer == EAtlasLayers.Depth399)
     {
         return("300~399:各种图标图集");
     }
     else if (eLayer == EAtlasLayers.Common_3)
     {
         return("400~499:common_3(" + COMMON_3 + ")");
     }
     else if (eLayer == EAtlasLayers.OtherAtlas)
     {
         return("500~599:其它图集");
     }
     else if (eLayer == EAtlasLayers.LabelText)
     {
         return("900~999:文字图集");
     }
     return("");
 }
Exemplo n.º 2
0
    //打印panel中的一个atlas的title
    void DrawOneTitle(ItemDepthConfig tempConfig)
    {
        float        height   = 32f;
        GameObject   PanelObj = tempConfig.panel;
        EAtlasLayers eLayer   = tempConfig.belongTo;
        string       sTitle   = GetLayerName(tempConfig.belongTo);

        GUILayout.BeginHorizontal();
        GUILayout.Box(sTitle, GUILayout.Width(250f));
        bool bClick = GUILayout.Button("重置选中项depth", "LargeButton", GUILayout.Width(160f), GUILayout.Height(height - 5f));

        if (bClick)
        {
            int layers = 1 << (int)eLayer;

            count_common1 = 0;
            count_common2 = 0;
            count_common3 = 0;
            count_uiatlas = 0;
            EachChildrenDepth(tempConfig.panel, tempConfig.panel, layers, true, true);
        }
        GUILayout.EndHorizontal();
    }
Exemplo n.º 3
0
    /// <summary>
    /// Draw the custom wizard.
    /// </summary>

    void OnGUI()
    {
        mScroll = GUILayout.BeginScrollView(mScroll);

        GameObject      tempPanel = null;
        bool            bBegin    = false;
        bool            bOpen     = false;
        EAtlasLayers    tempLayer = EAtlasLayers.Common_1;
        ItemDepthConfig tempConfig;

        for (int i = 0; i < _allItemsConfig.Count; i++)
        {
            tempConfig = _allItemsConfig[i];
            if ((tempPanel != null && tempPanel != tempConfig.panel) || (tempPanel != null && tempLayer != tempConfig.belongTo))
            {
                if (bBegin)
                {
                    NGUIEditorTools.EndContents();
                }
                bBegin = false;
            }

            if (tempPanel == null || tempPanel != tempConfig.panel)
            {
                DrawOnePanelName(tempConfig.panel);
            }
            if (tempPanel == null || tempLayer != tempConfig.belongTo)
            {
                //DrawOneTitle(tempConfig);
                string sTitle = GetLayerName(tempConfig.belongTo);
                string sKey   = tempConfig.panel.name + tempConfig.belongTo.ToString();
                bOpen = NGUIEditorTools.DrawHeader(sTitle, sKey);
                if (bOpen)
                {
                    NGUIEditorTools.BeginContents();
                    bBegin = true;
//                     GUILayout.BeginHorizontal();
//                     GUILayout.FlexibleSpace();
//                     bool bClick = GUILayout.Button("重置选中项depth", "LargeButton", GUILayout.Width(160f), GUILayout.Height(25f));
//                     if (bClick)
//                     {
//                         int layers = 1 << (int)tempConfig.belongTo;
//
//                         count_common1 = 0;
//                         count_common2 = 0;
//                         count_common3 = 0;
//                         count_uiatlas = 0;
//                         EachChildrenDepth(tempConfig.panel, tempConfig.panel, layers, true, true);
//                         SortAllItems();
//                     }
//                     GUILayout.FlexibleSpace();
//                     GUILayout.EndHorizontal();
                }
                else
                {
                    bBegin = false;
                }
            }
            if (bBegin)
            {
                DrawOneItem(ref tempConfig);
            }

            tempPanel = tempConfig.panel;
            tempLayer = tempConfig.belongTo;
        }
        if (bBegin)
        {
            NGUIEditorTools.EndContents();
        }

        GUILayout.EndScrollView();
        GUILayout.Space(6f);
        GUILayout.BeginHorizontal();
        GUILayout.Space(6f);
        bool bSelect = EditorGUILayout.ToggleLeft("选中所有", bSelectAll, GUILayout.Width(60f));

        if (bSelectAll != bSelect)
        {
            if (bSelect)
            {
                SelectAllItem();
            }
            else
            {
                UnSelectAllItem();
            }
            bSelectAll = bSelect;
        }
        GUILayout.FlexibleSpace();
        bool change = GUILayout.Button("自动适配所有选中项", "LargeButton", GUILayout.Width(160f));

        if (change)
        {
            SetChildrenDepth();
            ReadAllChildrenDepth();
        }
        GUILayout.FlexibleSpace();
        GUILayout.Space(-90f);
        bool bClickInstruction = GUILayout.Button("分段说明", "LargeButton", GUILayout.Width(90f));

        if (bClickInstruction)
        {
            NGUIDepthInstruction.ShowDialog();
        }
        GUILayout.EndHorizontal();
        GUILayout.Space(10f);
    }
Exemplo n.º 4
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="target">处理该目标下的孩子</param>
    /// <param name="atlasLayers">指定要处理的哪些层</param>
    /// <param name="bAutoSet">是否开启自动设置depth</param>
    /// <param name="bReadDepth">是否记录当前的depth</param>
    private static void EachChildrenDepth(GameObject uiPanel, GameObject target, int atlasLayers, bool bAutoSet = true, bool bReadDepth = false)
    {
        int             iCommon_1   = atlasLayers & (1 << (int)EAtlasLayers.Common_1);
        int             iDepth199   = atlasLayers & (1 << (int)EAtlasLayers.Depth199);
        int             iCommon_2   = atlasLayers & (1 << (int)EAtlasLayers.Common_2);
        int             iDepth399   = atlasLayers & (1 << (int)EAtlasLayers.Depth399);
        int             iCommon_3   = atlasLayers & (1 << (int)EAtlasLayers.Common_3);
        int             iOtherAtlas = atlasLayers & (1 << (int)EAtlasLayers.OtherAtlas);
        int             iLabelText  = atlasLayers & (1 << (int)EAtlasLayers.LabelText);
        int             iCount      = target.transform.childCount;
        int             curDepth    = 0;
        int             tempDepth   = 10000000;
        EAtlasLayers    tempType    = EAtlasLayers.OtherAtlas;
        ItemDepthConfig tempConfig;
        string          tempContent;
        bool            isAtlas;
        UIPanel         panel;
        UISprite        sprite;
        UILabel         label;
        UITexture       texture;

        for (int i = 0; i < iCount; i++)
        {
            GameObject objChild = target.transform.GetChild(i).gameObject;
            panel = objChild.GetComponent <UIPanel>();
            if (panel != null)
            {
                continue;               //该孩子为uipanel时跳过
            }
            tempConfig  = GetItemConfig(objChild);
            sprite      = objChild.GetComponent <UISprite>();
            curDepth    = 0;
            tempDepth   = 10000000;
            tempType    = tempConfig.belongTo;
            isAtlas     = false;
            tempContent = tempConfig.strContent;
            if (sprite != null && sprite.atlas != null) //如果是sprite
            {
//                 tempConfig = new ItemDepthConfig();
//                 tempConfig.bIgnor = false;

                isAtlas  = true;
                curDepth = sprite.depth;
                string atlasName = sprite.atlas.name;
                if (IsIconAtlas(atlasName))
                {
                    atlasName = "SOME_ICON_ATLAS";
                }
                if (atlasName != "" && atlasName == UIATLAS_NAME)
                {
                    atlasName = "CURRENT_UI_ATLAS";
                }

                if (atlasName == COMMON_1)
                {
                    if (iCommon_1 != 0)
                    {
                        tempDepth = count_common1;
                        count_common1++;
                        tempType    = EAtlasLayers.Common_1;
                        tempContent = "sprite:" + sprite.spriteName;
                    }
                }
                else if (atlasName == "CURRENT_UI_ATLAS")
                {
                    if (iDepth199 != 0)
                    {
                        tempDepth = 100 + count_uiatlas;
                        count_uiatlas++;
                        tempType    = EAtlasLayers.Depth199;
                        tempContent = "sprite:" + sprite.spriteName;
                    }
                }
                else if (atlasName == COMMON_2)
                {
                    if (iCommon_2 != 0)
                    {
                        tempDepth = 200 + count_common2;
                        count_common2++;
                        tempType    = EAtlasLayers.Common_2;
                        tempContent = "sprite:" + sprite.spriteName;
                    }
                }
                else if (atlasName == "SOME_ICON_ATLAS")
                {
                    if (iDepth399 != 0)
                    {
                        tempDepth   = 301;
                        tempType    = EAtlasLayers.Depth399;
                        tempContent = "sprite:" + sprite.spriteName;
                    }
                }
                else if (atlasName == COMMON_3)
                {
                    if (iCommon_3 != 0)
                    {
                        tempDepth = 400 + count_common3;
                        count_common3++;
                        tempType    = EAtlasLayers.Common_3;
                        tempContent = "sprite:" + sprite.spriteName;
                    }
                }
                else if (iOtherAtlas != 0)
                {
                    int index = GetIndexInOtherAtlas(atlasName);
                    tempDepth   = 500 + index * 10 + 1;
                    tempType    = EAtlasLayers.OtherAtlas;
                    tempContent = "Atlas:" + sprite.atlas.name + ", sprite:" + sprite.spriteName;
                }

                if (tempDepth != 10000000 && bAutoSet && !tempConfig.bIgnor)//有适配到值
                {
                    sprite.depth = tempDepth;
                    curDepth     = tempDepth;
                    if (objChild.CompareTag("OtherDepth"))
                    {
                        objChild.tag = "";
                    }
                }
            }

            label = objChild.GetComponent <UILabel>();
            if (label != null && iLabelText != 0) //如果是label
            {
//                 tempConfig = new ItemDepthConfig();
//                 tempConfig.bIgnor = false;

                isAtlas     = true;
                curDepth    = label.depth;
                tempType    = EAtlasLayers.LabelText;
                tempContent = "text:" + label.text;
                if (bAutoSet && !tempConfig.bIgnor)
                {
                    label.depth = 901;
                    curDepth    = label.depth;
                    if (objChild.CompareTag("OtherDepth"))
                    {
                        objChild.tag = "";
                    }
                }
            }
            texture = objChild.GetComponent <UITexture>();
            if (texture != null && iOtherAtlas != 0) //如果是uitexture
            {
//                 tempConfig = new ItemDepthConfig();
//                 tempConfig.bIgnor = false;

                isAtlas     = true;
                curDepth    = texture.depth;
                tempType    = EAtlasLayers.OtherAtlas;
                tempContent = "texture:" + texture.name;
                if (bAutoSet && !tempConfig.bIgnor)
                {
                    int index = GetIndexInOtherAtlas(texture.name);
                    texture.depth = 500 + index * 10 + 1;
                    curDepth      = texture.depth;
                    if (objChild.CompareTag("OtherDepth"))
                    {
                        objChild.tag = "";
                    }
                }
            }
            if (isAtlas && bReadDepth)
            {
                ESpecialType eType = GetSpecialDepth(curDepth);
                if (objChild.CompareTag("OtherDepth"))
                {
                    eType = ESpecialType.Other;
                }
                tempConfig.belongTo = tempType;
                if (!tempConfig.bIgnor)
                {
                    tempConfig.bIgnor = (eType != ESpecialType.Auto);
                }
                tempConfig.target      = objChild;
                tempConfig.specialType = "";
                tempConfig.eSpecial    = eType;
                tempConfig.panel       = uiPanel;
                tempConfig.idepth      = curDepth;
                tempConfig.strContent  = tempContent;
                AddItemConfig(tempConfig);
            }
            EachChildrenDepth(uiPanel, objChild, atlasLayers, bAutoSet, bReadDepth);
        }
    }