static int UpdateControlBind(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         CFramework.LuaComponent obj = (CFramework.LuaComponent)ToLua.CheckObject <CFramework.LuaComponent>(L, 1);
         obj.UpdateControlBind();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int New(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         CFramework.LuaComponent obj = (CFramework.LuaComponent)ToLua.CheckObject <CFramework.LuaComponent>(L, 1);
         LuaTable            arg0    = ToLua.CheckLuaTable(L, 2);
         CFramework.BaseView arg1    = (CFramework.BaseView)ToLua.CheckObject <CFramework.BaseView>(L, 3);
         obj.New(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
示例#3
0
        public Transform AddChild(Transform parent, Transform go, string preStr = null)
        {
            DebugManager.Log("AddChild:" + go.name + "," + preStr);
            if (preStr != null)
            {
                go.name = preStr + "_" + go.name;
                FormatChildName(go, preStr);
            }

            go.transform.parent = parent.transform;

            initView(go);

            LuaComponent luaComponent = _uiRoot.GetComponent <LuaComponent>();

            luaComponent.UpdateControlBind();

            return(go);
        }
示例#4
0
        /// <summary>
        /// 添加一个场景窗口
        /// </summary>
        /// <param name="id"></param>
        /// <param name="preloadList"></param>
        /// <param name="luaWindowClass"></param>
        /// <param name="progressCallback"></param>
        /// <param name="isCahce"></param>
        public void AddWindow(string id, string abName, string assetName, string[] preloadList, bool isModal, LuaTable luaWindowClass,
                              LuaFunction progressCallback, bool isClickExit, bool isCache = false)
        {
            if (this.CurrScene == null)
            {
                DebugManager.LogError("AddPopup Error:当前没有可用的场景!");

                return;
            }

            this.CurrScene.AddWindow(id, abName, assetName, preloadList, isModal, isCache, isClickExit, delegate(BaseWindow window) {
                LuaComponent luaComponent = window.UiRoot.gameObject.AddComponent <LuaComponent>();
                luaComponent.New(luaWindowClass, window);

                if (progressCallback != null)
                {
                    progressCallback.Call();
                }
            }, delegate(int count, int total) {
            });
        }
示例#5
0
        /// <summary>
        /// 启动loading场景
        /// </summary>
        /// <returns></returns>
        private IEnumerator StartLoadingScene(string sceneId, string loadingWindowId,
                                              LuaTable loadingWindowClass)
        {
            Scene loadingScene = SceneManager.GetSceneByName("LoadingScene");

            yield return(new WaitUntil(delegate() {
                return loadingScene.isLoaded;
            }));

            Debug.Log("LoadingScene complete");

            string assetName = ("prefabs/" + loadingWindowId + ".unity3d").ToLower();

            ResourceManager.Instance.LoadPrefabAsync("LoadingScene", assetName, delegate(AssetBundle asset) {
                //先显示加载窗口
                GameObject loadingWindowAsset = ResourceManager.Instance.GetAsset(asset, loadingWindowId).gameObject;

                loadingWindowAsset.AddComponent <LuaComponent>();
                GameObject loadingWindow  = Instantiate(loadingWindowAsset, GameObject.Find("WindowLayer").transform);
                LuaComponent luaComponent = loadingWindow.GetComponent <LuaComponent>();
                luaComponent.New(loadingWindowClass, new BaseWindow(loadingWindowId, null, false, loadingWindow.transform));
                loadingWindow.name = loadingWindowId;


                //启动预加载资源加载
                ResourceManager.Instance.LoadPrefabAsync(_id, _preloadList, delegate(List <AssetBundle> assetBundle) {
                    _preloadIsEnd = true;

                    //启动场景加载
                    _prog = SceneManager.LoadSceneAsync(sceneId);
                    _prog.allowSceneActivation = false;  //如果加载完成,也不进入场景
                });

                //启动加载进度条
                StartCoroutine(LoadingScene(loadingWindowClass));
            });
        }
示例#6
0
        /// <summary>
        /// 加载场景
        /// </summary>
        /// <param name="loadingWindowClass"></param>
        /// <returns></returns>
        private IEnumerator LoadingScene(LuaTable loadingWindowClass)
        {
            int showProgress = 80;

            while (showProgress < 100)
            {
                if (showProgress < 30)
                {
                    showProgress++;

                    if (_progressCallback != null)
                    {
                        _progressCallback(showProgress);
                        loadingWindowClass.Call("OnProgress", loadingWindowClass, showProgress);
                        yield return(new WaitForEndOfFrame()); //等待一帧
                    }
                }
                else if (showProgress < 90)
                {
                    yield return(new WaitUntil(delegate()
                    {
                        return _preloadIsEnd;
                    }));

                    showProgress++;

                    if (_progressCallback != null)
                    {
                        _progressCallback(showProgress);
                        loadingWindowClass.Call("OnProgress", loadingWindowClass, showProgress);
                        yield return(new WaitForEndOfFrame()); //等待一帧
                    }
                }
                else
                {
                    yield return(new WaitUntil(delegate()
                    {
                        return _prog.progress >= 0.9f;
                    }));

                    showProgress++;
                    if (_progressCallback != null)
                    {
                        _progressCallback(showProgress);
                        loadingWindowClass.Call("OnProgress", loadingWindowClass, showProgress);
                        yield return(new WaitForEndOfFrame()); //等待一帧
                    }
                }
            }

            //-----------------------------预加载资源加载完成,进入场景------------------------------
            _prog.allowSceneActivation = true;  //如果加载完成,可以进入场景

            Scene scene = SceneManager.GetSceneByName(_id);

            yield return(new WaitUntil(delegate() {
                return scene.isLoaded;
            }));

            DebugManager.Log("enter scene:" + scene.name);

            GameObject[] objs = scene.GetRootGameObjects();

            foreach (GameObject go in objs)
            {
                DebugManager.Log("go.name:" + go.name);
                if (go.name.Equals("Canvas"))
                {
                    _loadBaseScene = new BaseScene(_id, _preloadList, _completeCallback, _progressCallback, _isCache, go.transform);
                    LuaComponent luaComponent = go.AddComponent <LuaComponent>();

                    luaComponent.New(_luaSceneClass, _loadBaseScene);

                    _completeCallback(_loadBaseScene);

                    this.CurrScene = _loadBaseScene;

                    _loadBaseScene = null;
                    _id            = null;
                    break;
                }
            }
        }