Пример #1
0
    public override void InitWindowManager()
    {
        base.InitWindowManager();
        InitWindowControl();
        isNeedWaitHideOver = true;
        DontDestroyOnLoad(UIRoot);

        if (UIFixedWidowRoot == null)
        {
            UIFixedWidowRoot = new GameObject("UIFixedWidowRoot").transform;
            GameUtility.AddChildToTarget(UIRoot, UIFixedWidowRoot);
            GameUtility.ChangeChildLayer(UIFixedWidowRoot, UIRoot.gameObject.layer);
        }
        if (UIPopUpWindowRoot == null)
        {
            UIPopUpWindowRoot = new GameObject("UIPopUpWindowRoot").transform;
            GameUtility.AddChildToTarget(UIRoot, UIPopUpWindowRoot);
            GameUtility.ChangeChildLayer(UIPopUpWindowRoot, UIRoot.gameObject.layer);
        }
        if (UINormalWindowRoot == null)
        {
            UINormalWindowRoot = new GameObject("UINormalWindowRoot").transform;
            GameUtility.AddChildToTarget(UIRoot, UINormalWindowRoot);
            GameUtility.ChangeChildLayer(UINormalWindowRoot, UIRoot.gameObject.layer);
        }
    }
Пример #2
0
    private void InitLoopScrollView()
    {
        int realItemIndex = this.minLoopCount;

        this.itemScripts.Clear();
        this.mChildren.Clear();

        if (this.minLoopCount > this.itemDatas.Count)
        {
            // just add child.
            realItemIndex = this.itemDatas.Count;
            isInLoop      = false;

            this.curMaxDataIndex = this.itemDatas.Count;
            this.curMinDataIndex = 0;
        }
        else
        {
            this.curMinDataIndex = 0;
            this.curMaxDataIndex = this.minLoopCount - 1;
            this.isInLoop        = true;
        }

        // set the grid sort method
        // 设置grid的排序规则,防止出现排序位置显示错误
        this.mGrid.sorting = UIGrid.Sorting.Alphabetic;

        for (int i = 0; i < realItemIndex; i++)
        {
            // get item from the free game object list
            // GameObject obj = GameObject.Instantiate(this.prefab);
            GameObject obj = this.GetFreeItem();
            if (obj == null)
            {
                obj = GameObject.Instantiate(this.prefab);
            }
            if (!obj.activeSelf)
            {
                obj.SetActive(true);
            }

            GameUtility.AddChildToTarget(mGrid.transform, obj.transform);
            UIWidget widget = obj.GetComponent <UIWidget>();
            this.mChildren.Add(widget);
            this.mChildrenStatus[widget] = false;

            // 设置排序规则保证第一次显示顺序一致
            // set the item right name to sort right
            //obj.name = i.ToString();
            // get the sorted name
            obj.name = i.ToString("D5");
            LoopBaseItem itemScript = obj.GetComponent <LoopBaseItem>();
            itemScript.CurItemIndex = i;
            itemScript.UpdateData(this.itemDatas[i]);
            this.itemScripts.Add(itemScript);
        }
        mGrid.Reposition();
        this.mScrollView.ResetPosition();
        this.UpdateItemVisable(true);
        Debuger.Log("@view item count is " + this.itemDatas.Count);
    }
Пример #3
0
    protected override UIBaseWindow ReadyToShowBaseWindow(WindowID id, ShowWindowData showData = null)
    {
        // 检测控制权限
        if (!this.IsWindowInControl(id))
        {
            Debug.Log("UIManager has no control power of " + id.ToString());
            return(null);
        }
        if (shownWindows.ContainsKey(id))
        {
            return(null);
        }

        // 隐藏callWindowId指向窗口

        /*if(showData != null)
         *  HideWindow(showData.callWindowId, null);*/

        UIBaseWindow baseWindow = GetGameWindow(id);
        bool         newAdded   = false;

        if (!baseWindow)
        {
            newAdded = true;
            // 窗口不存在从内存进行加载
            if (UIResourceDefine.windowPrefabPath.ContainsKey(id))
            {
                string     prefabPath = UIResourceDefine.UIPrefabPath + UIResourceDefine.windowPrefabPath[id];
                GameObject prefab     = Resources.Load <GameObject>(prefabPath);
                if (prefab != null)
                {
                    GameObject uiObject = (GameObject)GameObject.Instantiate(prefab);
                    NGUITools.SetActive(uiObject, true);
                    baseWindow = uiObject.GetComponent <UIBaseWindow>();
                    // 需要动态添加对应的控制界面,prefab不用添加脚本
                    Transform targetRoot = GetTargetRoot(baseWindow.windowData.windowType);
                    GameUtility.AddChildToTarget(targetRoot, baseWindow.gameObject.transform);
                    allWindows[id] = baseWindow;
                }
            }
        }

        if (baseWindow == null)
        {
            Debug.LogError("[window instance is null.]" + id.ToString());
        }

        // 重置界面(第一次添加,强制Reset)
        if (newAdded || (showData != null && showData.forceResetWindow))
        {
            baseWindow.ResetWindow();
        }

        // 显示界面固定内容


        // 导航系统数据更新
        RefreshBackSequenceData(baseWindow);
        // 调整层级depth
        AdjustBaseWindowDepth(baseWindow);
        // 添加背景Collider
        AddColliderBgForWindow(baseWindow);
        return(baseWindow);
    }