Beispiel #1
0
 /// <summary>
 /// 取消记录
 /// </summary>
 /// <param name="view"></param>
 public void UnRecordView(UIBaseView view)
 {
     if (view == null || string.IsNullOrEmpty(view.name))
     {
         Debug.LogError("UnRecordView" + (view == null));
         return;
     }
     if (m_AllExitView.ContainsKey(view.name))
     {
         m_AllExitView.Remove(view.name);
     }
 }
Beispiel #2
0
 /*public void OnUIFadeIned(UIBaseView ui)
  * {
  *  if (null == ui || ui.UI类型 <= UIViewType.Root2D || ui.UI类型 >= UIViewType.弹出框)
  *      return;
  *  if (!mFadeInedChilden.Contains(ui))
  *      mFadeInedChilden.Add(ui);
  *  if (mActivedChilden.Contains(ui))
  *                      mActivedChilden.Remove(ui);
  *              NoFightMainView view = NoFightMainView.Inst;
  *              if (null != view && !(ui is NoFightMainView) && !(ui is FightingMainView))
  *                      view.OnUpdateGuide(false, false);
  * }*/
 void OnUIViewFadeOuted(UIBaseView sender)
 {
     if (null == sender || sender.UI类型 <= UIViewType.Root2D || sender.UI类型 >= UIViewType.弹出框)
     {
         return;
     }
     if (mFadeInedChilden.Contains(sender))
     {
         mFadeInedChilden.Remove(sender);
     }
     mFadeOutedChilden.Add(sender);
 }
Beispiel #3
0
 /// <summary>
 /// 记录存在的UI
 /// </summary>
 /// <param name="view"></param>
 public void RecordView(UIBaseView view)
 {
     if (view == null || string.IsNullOrEmpty(view.name))
     {
         Debug.LogError("RecordView" + (view == null));
         return;
     }
     if (m_AllExitView.ContainsKey(view.name) == false)
     {
         m_AllExitView.Add(view.name, view);
     }
 }
Beispiel #4
0
    public static UIBaseView CreateView(BaseController baseController)
    {
        string name = baseController.GetPath();
        //Debug.LogError(name);
        GameObject go   = Instantiate(Resources.Load(UIPATH + name)) as GameObject;
        UIBaseView view = go.GetComponent <UIBaseView>();

        go.transform.parent        = Instance.transform;
        go.transform.localPosition = Vector3.zero;
        go.transform.localScale    = Vector3.one;
        view.InitView(baseController);
        return(view);
    }
        /// <summary>
        /// Position the grid's contents when the script starts.
        /// </summary>
        protected virtual void Start()
        {
#if UNITY_EDITOR
            UIBaseView bv      = GetComponentInParent <UIBaseView>();
            Transform  pparent = transform.parent.parent;
            if (keepWithinPanel)
            {
                Debug.LogError("ScrollTable[" + bv.name + "/" + pparent.name + "]sure enable panel moving?");
            }
#endif
            Init();
            Reposition();
            enabled = false;
        }
 public void ShowAsSecondView(UIViewLayer currViewLayer)
 {
     if (CheckViewExist())
     {
         ShowAsSecondViewImpl(currViewLayer);
     }
     else
     {
         LoadRawView(uiViewDeploy, _uiView =>
         {
             uiView      = _uiView;
             uiView.args = args;
             ShowAsSecondViewImpl(currViewLayer);
         });
     }
 }
Beispiel #7
0
        /* void OnTouchsObjectEnded(RaycastHit[] cs, Vector3 worldPos)
         * {
         *   if (null == mTouchsBeginObj || mTouchsBeginObj.Length <= 0)
         *       return;
         *   if ((mTouchsBeginWorldPos - worldPos).magnitude < 0.5f)
         *   {
         *       List<Player> pls = new List<Player>();
         *       List<Npc> npcs = new List<Npc>();
         *       for (int i = 0; i < mTouchsBeginObj.Length; ++i)
         *       {
         *           if (null == mTouchsBeginObj[i].collider)
         *               continue;
         *           ControllerBase ctrl = mTouchsBeginObj[i].collider.GetComponent<ControllerBase>();
         *           if (null == ctrl || null == ctrl.SceneObject)
         *               continue;
         *           if (!(ctrl.SceneObject is ICharacter))
         *               continue;
         *           ICharacter chara = ctrl.SceneObject as ICharacter;
         *           if (chara.IsPlayer && !chara.IsLocalPlayer)
         *               pls.Add(chara as Player);
         *           else if (chara.IsNpc)
         *               npcs.Add(chara as Npc);
         *       }
         *       if (pls.Count > 0 || npcs.Count > 0)
         *       {
         *           if(null != NoFightMainView.Inst)
         *           {
         *               if (pls.Count == 1 && npcs.Count <= 0)
         *               {
         *                   if (pls[0].BaseInfo.InRing)
         *                   {
         *                       RingRoomView view = UIViewHelper.LoadUIViewRes<RingRoomView>(UIViewType.擂台界面);
         *                       view.BindPlayer(pls[0]);
         *                   }
         *                   else
         *                       PopupDialogView.Popup(PopupDialogType.玩家功能列表, NoFightMainView.Inst.gameObject, pls[0].ActorID, pls[0].ActorName);
         *               }
         *               else  if (npcs.Count == 1 && pls.Count <= 0)
         *               {
         *                   NpcLuaTable.ValDesc data = NpcLuaTable.Inst[npcs[0].NpcID];
         *                   if (null != data)
         *                   {
         *                       if(data.TaskData.Count > 0 || (null != data.Functions && data.Functions.Length > 0))
         *                           PopupDialogView.Popup(PopupDialogType.NPC功能列表, NoFightMainView.Inst.gameObject, npcs[0]);
         *                   }
         *               }
         *               else
         *                   PopupDialogView.Popup(PopupDialogType.场景对象列表, NoFightMainView.Inst.gameObject, worldPos, npcs, pls);
         *           }
         *       }
         *   }
         * }*/
        public void OnUIActived(UIBaseView ui)
        {
            if (null == ui || ui.UI类型 <= UIViewType.Root2D || ui.UI类型 >= UIViewType.弹出框)
            {
                return;
            }
            if (!mActivedChilden.Contains(ui))
            {
                if (ui.IsFadePanel)
                {
//                    ui.OnFadeInOvered += new UIBaseView.FadeEventHandler(OnUIFadeIned);
                    ui.OnFadeOutOvered += new UIBaseView.FadeEventHandler(OnUIViewFadeOuted);
                    //                  ui.OnDestroyed += new UIBaseView.DestroyEventHandler(OnUIDestroyed);
                }
                mActivedChilden.Add(ui);
            }
        }
Beispiel #8
0
 public void ShowLeft(BaseController baseController)
 {
     if (LeftView == null)
     {
         LeftView = CreateView(baseController);
     }
     else
     {
         if (LeftView.controller.GetPath() == baseController.GetPath())
         {
             LeftView.CloseView();
             return;
         }
         LeftView.CloseView();
         LeftView = CreateView(baseController);
     }
 }
Beispiel #9
0
 public void ShowRight(BaseController baseController)
 {
     if (RightView == null)
     {
         RightView = CreateView(baseController);
     }
     else
     {
         if (RightView.controller.GetPath() == baseController.GetPath())
         {
             RightView.CloseView();
             RightView = null;
             return;
         }
         RightView.CloseView();
         RightView = CreateView(baseController);
     }
 }
    private static void LoadRawView(UIViewDeploy viewDeploy, Action <UIBaseView> callback)
    {
        string viewPath = viewDeploy.viewPath;

        LoadResourceToViewLayer(viewPath, viewDeploy.uiViewLayer, gameObject =>
        {
            UIBaseView uiBaseView = null;
            if (!string.IsNullOrEmpty(viewDeploy.entityClass))
            {
                Type entityClass = Type.GetType(viewDeploy.entityClass);
                uiBaseView       = gameObject.AddComponent(entityClass).gameObject.GetComponent <UIBaseView>();
            }

            if (callback != null)
            {
                callback(uiBaseView);
            }
        });
    }
Beispiel #11
0
 //IEnumerator DoLoadAtlas(UIAtlasType t, UISpriteEx spEx)
 //{
 //    int aid = (int)t;
 //    if (!mAtlasList.ContainsKey(aid) || string.IsNullOrEmpty(mAtlasList[aid].Middle))
 //        Debug.LogError("找不到图包[" + t.ToString() + "]对应的资源!");
 //    else
 //    {
 //        if (!mAtlasRefCounts.ContainsKey(aid))
 //        {
 //            ThreeData<UIAtlas, string, Vector2> data = mAtlasList[aid];
 //            yield return StartCoroutine(DoLoadAtlas(data.Bgein, aid, data.Middle));
 //        }
 //        mAtlasRefCounts[aid]++;
 //        if (null != spEx)
 //            spEx.OnAtlasLoaded(t, mAtlasList[aid].Bgein);
 //    }
 //}
 IEnumerator DoLoadAtlas(int aid, UIBaseView view)
 {
     if (!mAtlasList.ContainsKey(aid) || string.IsNullOrEmpty(mAtlasList[aid].Middle))
     {
         Debug.LogError("找不到图包[" + ((UIAtlasType)aid).ToString() + "]对应的资源!");
     }
     else
     {
         if (!mAtlasRefCounts.ContainsKey(aid))
         {
             ThreeData <UIAtlas, string, Vector2> data = mAtlasList[aid];
             yield return(StartCoroutine(DoLoadAtlas(data.Bgein, aid, data.Middle)));
         }
         mAtlasRefCounts[aid]++;
     }
     if (null != view)
     {
         view.OnAtlasLoaded((UIAtlasType)aid);
     }
 }
Beispiel #12
0
    public void CloseView(UIViewName uiName)
    {
        string ViewName = uiName.ToString();

        if (!openViewDict.ContainsKey(ViewName))
        {
            return;
        }
        GameObject ui = openViewDict[ViewName];

        openViewDict.Remove(ViewName);
        closeViewDict[ViewName] = ui;
        UIBaseView uiView = ui.GetComponent <UIBaseView>();

        uiView.CloseView();

        ui.transform.parent           = hideLayer;
        ui.transform.localScale       = Vector3.one;
        ui.transform.localEulerAngles = Vector3.zero;
        ui.transform.localPosition    = Vector3.zero;
    }
Beispiel #13
0
    public void OpenView(UIViewName uiName, params object[] param)
    {
        for (int i = 0; i < openViewStack.Count; ++i)
        {
            CloseView(openViewStack[i]);
        }
        openViewStack.Clear();
        openViewStack.Add(uiName);

        string ViewName = uiName.ToString();

        if (openViewDict.ContainsKey(ViewName))
        {
            return;
        }
        GameObject ui = null;

        if (closeViewDict.ContainsKey(ViewName))
        {
            ui = closeViewDict[ViewName];
            closeViewDict.Remove(ViewName);
            openViewDict[ViewName] = ui;
        }
        else
        {
            GameObject resGo = Resources.Load <Object>("Prefab/UI/" + ViewName) as GameObject;
            ui = GameObject.Instantiate(resGo);
            CanvasDepth cd = ui.AddComponent <CanvasDepth>();
            cd.isUI = true;
            openViewDict[ViewName] = ui;
        }
        ui.transform.parent           = openLayer;
        ui.transform.localScale       = Vector3.one;
        ui.transform.localEulerAngles = Vector3.zero;
        ui.transform.localPosition    = Vector3.zero;
        UIBaseView uiView = ui.GetComponent <UIBaseView>();

        uiView.OpenView(param);
    }
 public void ShowAsTopView(Action <UIBaseView> callback = null)
 {
     if (CheckViewExist())
     {
         SetAsLastSibling(true);
         if (callback != null)
         {
             callback(uiView);
         }
     }
     else
     {
         LoadRawView(uiViewDeploy, _uiView =>
         {
             uiView      = _uiView;
             uiView.args = args;
             SetAsLastSibling(true);
             if (callback != null)
             {
                 callback(uiView);
             }
         });
     }
 }
Beispiel #15
0
        public virtual void ExportSettings()
        {
            if (null == 单元模板)
            {
                单元模板 = new GameObject("模板");
                Transform trans = 单元模板.transform;
                trans.parent        = transform;
                trans.localPosition = Vector3.zero;
                trans.localScale    = Vector3.one;
                trans.localRotation = Quaternion.identity;
            }
            if (单元模板.activeSelf)
            {
                单元模板.SetActive(false);
            }
            if (表格 == null)
            {
                表格 = GetComponentInChildren <ScrollTable>();
            }
            if (表格 == null)
            {
                表格 = GetComponent <ScrollTable>();
            }
            if (null != 滚动视图 && null != 表格)
            {
                switch (滚动视图.movement)
                {
                case Movement.Horizontal:
                {
                    switch (表格.容器锚点)
                    {
                    case UIWidget.Pivot.Center:
                    case UIWidget.Pivot.Top:
                    case UIWidget.Pivot.Bottom:
                        break;

                    default:
                    {
                        UIBaseView view = GetComponentInParent <UIBaseView>();
                        Debug.LogError("ScrollViewport[" + view.name + "/" + transform.parent.name + "]can only use center with context pivot!");
                    }
                    break;
                    }
                }
                break;

                case Movement.Vertical:
                {
                    switch (表格.容器锚点)
                    {
                    case UIWidget.Pivot.Center:
                    case UIWidget.Pivot.Left:
                    case UIWidget.Pivot.Right:
                        break;

                    default:
                    {
                        UIBaseView view = GetComponentInParent <UIBaseView>();
                        Debug.LogError("ScrollViewport[" + view.name + "/" + transform.parent.name + "]can only use center with context pivot!");
                    }
                    break;
                    }
                }
                break;
                }
            }
            滚动视图.内容锚点 = 表格.容器锚点;
        }
 public ViewNode(UIBaseView uiView, UIViewDeploy uiViewDeploy, object[] args)
 {
     this.uiView       = uiView;
     this.uiViewDeploy = uiViewDeploy;
     this.args         = args;
 }
Beispiel #17
0
 public void DeleteRight()
 {
     RightView = null;
 }
Beispiel #18
0
 public void DeleteLeft()
 {
     LeftView = null;
 }
Beispiel #19
0
 public void Start()
 {
     Instance = this;
     MainController mainController = new MainController();
     UIBaseView     view           = CreateView(mainController);
 }