Пример #1
0
 static public void setLayer(GameObject go, int layer)
 {
     go.layer = layer;
     foreach (Transform t in go.transform)
     {
         Unity3Tools.setLayer(t.gameObject, layer);
     }
 }
Пример #2
0
    public static UI3Wnd createWindow(string className)
    {
        UI3Wnd window = findWindow(className);

        if (window != null)
        {
            return(window);
        }

        GameObject res = loadWindowRes(className) as GameObject;

        if (res == null)
        {
            return(null);
        }

        GameObject parent = getWndRootPanel(className);
        GameObject uiGo   = NGUITools.AddChild(parent, res);

        UIAnchor[] Anchor = uiGo.GetComponentsInChildren <UIAnchor>(true);
        for (int i = 0; i < Anchor.Length; ++i)
        {
            if (Anchor[i].uiCamera == null)
            {
                Anchor[i].uiCamera = Unity3Tools.FindInParent <Camera>(uiGo);
            }
        }
        uiGo.SetActive(false);

        window = uiGo.AddMissingComponent <UI3Wnd>();

        int layerDepth = 0;
        UI3WndPanelLayerType layerType = (UI3WndPanelLayerType)Enum.Parse(typeof(UI3WndPanelLayerType), window.panelLayerType);

        if (UI3WndPanelLayer.layers.Length > (int)layerType)
        {
            layerDepth = UI3WndPanelLayer.layers[(int)layerType].begin;
        }
        window.addDepth(layerDepth);

        UIResInfo resInfo = m_resInfoDict[className];

        if (resInfo != null)
        {
            window.WndType = resInfo.type;
            resInfo.objList.Add(uiGo);
        }

        window.ClassMark = resInfo.uiMark;

        return(window);
    }
Пример #3
0
    // 创建
    public static T createWindow <T>(GameObject parent, bool bSingle) where T : UI3Wnd
    {
        if (bSingle)
        {
            T window = findWindow <T>();
            if (window != null)
            {
                return(window);
            }
        }

        GameObject res = loadWindowRes <T>() as GameObject;

        if (res == null)
        {
            return(null);
        }

        GameObject uiGo = NGUITools.AddChild(parent, res);

        UIAnchor[] Anchor = uiGo.GetComponentsInChildren <UIAnchor>(true);
        for (int i = 0; i < Anchor.Length; ++i)
        {
            if (Anchor[i].uiCamera == null)
            {
                Anchor[i].uiCamera = Unity3Tools.FindInParent <Camera>(uiGo);
            }
        }
        uiGo.SetActive(false);

        T t = uiGo.AddMissingComponent <T>();

        string    className = typeof(T).ToString();
        UIResInfo resInfo   = m_resInfoDict[className];

        if (resInfo != null)
        {
            t.WndType        = resInfo.type;
            t.panelLayerType = resInfo.layerType;
            resInfo.objList.Add(uiGo);
        }

        ((UI3Wnd)t).ClassMark = resInfo.uiMark;

        return(t);
    }