コード例 #1
0
ファイル: ViewSys.cs プロジェクト: DongerGroup/FrameSync-1
 public void Open(string name, ViewParam param = null)
 {
     if (!_views.ContainsKey(name))
     {
         string clsName = name + "Controller";
         Type   type    = Type.GetType(clsName);
         if (type == null)
         {
             type = typeof(BaseViewController);
         }
         object obj = Activator.CreateInstance(type);
         if (obj == null)
         {
             CLog.LogError("Cannot find class with type [" + type + "].");
             return;
         }
         BaseViewController controller = obj as BaseViewController;
         controller.viewName = name;
         controller.viewPath = GetViewPath(name);
         //_views.Add(name, controller);
         m_cContainer.Add(controller, param);
     }
     else
     {
         _views[name].Open(param);
     }
 }
コード例 #2
0
ファイル: ViewSys.cs プロジェクト: DongerGroup/FrameSync-1
        private void OnAdd(IDynamicObj obj, object param)
        {
            BaseViewController controller = obj as BaseViewController;
            ViewParam          p          = param as ViewParam;

            _views.Add(controller.viewName, controller);
            controller.Open(p);
        }
コード例 #3
0
ファイル: ViewSys.cs プロジェクト: DongerGroup/FrameSync-1
        private void OnUpdate(IDynamicObj obj, object param)
        {
            BaseViewController controller = obj as BaseViewController;

            if (controller.isActive)
            {
                controller.OnUpdate();
            }
        }
コード例 #4
0
ファイル: ViewSys.cs プロジェクト: DongerGroup/FrameSync-1
        private void OnRemove(IDynamicObj obj, object param)
        {
            BaseViewController controller = obj as BaseViewController;

            if (controller != null)
            {
                controller.Destroy();
            }
            _views.Remove(name);
        }
コード例 #5
0
        private void OnLoadViewRes(Resource res, bool succ)
        {
            if (succ)
            {
                string             viewname = ViewConfig.GetViewName(res.path);
                BaseViewController vc;
                //此处为修改框架,防止同时存在两个view,直接覆盖
                if (views.TryGetValue(viewname, out vc))
                {
                    views.Remove(viewname);
                    vc.Close();
                }
                GameObject go = GameObject.Instantiate(res.UnityObj) as GameObject;

                switch (ViewConfig.Instance.GetViewCo(viewname).viewtype)
                {
                case ViewType.Dialog:
                    go.transform.SetParent(DialogRoot, false);
                    break;

                case ViewType.Window:
                    go.transform.SetParent(WindowRoot, false);
                    break;

                case ViewType.Full:
                    go.transform.SetParent(FullScreenRoot, false);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                vc = BaseViewController.Create(viewname, go);


                views.Add(viewname, vc);
                //从此处跳转到View覆盖方法
                vc.Build();
                vc.OnBuild();
                vc.Open();
                vc.OnOpen();

//                Debug.Log(string.Format("<color=#ffffffff><---{0}-{1}----></color>", go.name, "test1"));

                GlobalDispatcher.Instance.Dispatch(GlobalEvent.OnViewLoadFinished, go);
            }
            else
            {
                Debug.LogError("load view " + res.path + " fail");
            }
        }
コード例 #6
0
        public static BaseViewController Create(string viewname, GameObject mainGo)
        {
            string typename = "Game." + viewname + "Controller";
            //Debugger.Log(typename);
            Assembly ab = Assembly.GetExecutingAssembly();

            for (int i = 0; i < ab.GetManifestResourceNames().Length; i++)
            {
                Debug.Log(string.Format("<color=#ffffffff><---{0}-{1}----></color>", ab.GetManifestResourceNames()[i], "test1"));
            }
            BaseViewController vc = (BaseViewController)Assembly.GetExecutingAssembly().CreateInstance(typename);

            vc.MainGO = mainGo;
            return(vc);
        }
コード例 #7
0
 protected BaseSubView(GameObject targetGo, BaseViewController viewController)
 {
     this.TargetGo       = targetGo;
     this.ViewController = viewController;
 }