Esempio n. 1
0
 static int UIInit(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         MyFrameWork.BaseUI obj = (MyFrameWork.BaseUI)ToLua.CheckObject(L, 1, typeof(MyFrameWork.BaseUI));
         obj.UIInit();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Esempio n. 2
0
        private void OnLoadUIFinished(object asset, Command cmd)
        {
            if (asset != null && cmd != null)
            {
                GameObject go = null;
                if (AppConst.PrefabBundleMode && cmd.UIType != E_UIType.Fight &&
                    cmd.UIType != E_UIType.UILoadingPanel &&
                    cmd.UIType != E_UIType.PanelMessageBox &&
                    cmd.UIType != E_UIType.UILoginPanel)
                {
                    WWWRequestHandle handle    = asset as WWWRequestHandle;
                    AssetBundle      bundle    = handle.RetainAsAssetBundle();
                    GameObject       LoadedRes = bundle.LoadAsset(cmd.UIType.ToString()) as GameObject;
                    if (LoadedRes != null)
                    {
                        go = GameObject.Instantiate(LoadedRes) as GameObject;
                    }
                }
                else
                {
                    go = asset as GameObject;
                }
                go.SetActive(false);
                BaseUI ui = go.AddComponent(cmd.MonoType) as BaseUI;
                if (cmd.bLuaBehaviour)
                {
                    go.AddComponent <LuaBehaviour>().OnInit(null);
                }
                ui.mUIType = cmd.UIType;
                go.name    = ui.GetUIType().ToString();
                _curUI     = ui;
                if (ui.mUIStyle == E_UIStyle.BackClose)
                {
                    _backSequence.Push(ui);
                }
                AddUI(ui);

                if (ui.mUIType == E_UIType.UILoadingPanel)
                {
                    GameObject.DontDestroyOnLoad(go);
                }

                if (cmd.CommandType == Command.CmdType.CreateAndShow)
                {
                    if (cmd.lua_fun != null)
                    {
                        ShowUI_LUA(cmd.UIType, cmd.lua_fun, cmd.IsCloseOtherUIs, cmd.CreateCanCall, cmd.Params);
                    }
                    else
                    {
                        ShowUI(cmd.UIType, cmd.MonoType, cmd.Listener, cmd.IsCloseOtherUIs, cmd.CreateCanCall, cmd.Params);
                    }
                }
                else if (cmd.CreateCanCall && cmd.Listener != null)
                {
                    cmd.Listener(ui);
                }
                else if (cmd.CreateCanCall && cmd.lua_fun != null)
                {
                    cmd.lua_fun.Call(ui.gameObject);
                }
                //ui.CachedTransform.SetParent(UIContainer,false);

                ui.UIInit();

                AddColliderBgForWindow(ui);

                LayerMgr.Instance.SetLayer(ui);
            }
        }