private void LoadWebBrowser() { if (m_browserInstance != null) { return; } if (WebBrowserProgressBar != null) { WebBrowserProgressBar.gameObject.SetActive(true); } m_webBrowserResNode = UISystem.Instance.GetResNode("UI/Widgets/WebBrowser/WebBrowser"); if (m_webBrowserResNode == null || !m_webBrowserResNode.IsValid()) { return; } m_browserInstance = m_webBrowserResNode.InstanceMainRes <UBrowser>(); if (m_browserInstance == null) { return; } if (m_browserInstance.WebBrowserToolbar != null) { m_browserInstance.WebBrowserToolbar.gameObject.SetActive(false); } m_browserInstance.Width = (int)WebBrowserSize.x; m_browserInstance.Height = (int)WebBrowserSize.y; m_browserInstance.InitialURL = m_curUrl == "" ? WebBrowserUrl : m_curUrl; m_browserInstance.GetRectTransform.SetParent(WebBrowserContainer, false); m_reqUrlList.AddLast(m_browserInstance.InitialURL); m_browserInstance.OnPageLoadedEvent.RemoveListener(OnPageLoadedEvent); m_browserInstance.OnPageLoadedEvent.AddListener(OnPageLoadedEvent); }
public void OnAdvanceLoginClick(int nLoginType) { if (nLoginType < 0 || nLoginType > (int)EAdvanceLoginType.EALT_WeChat) { return; } AdvanceLoginType = (EAdvanceLoginType)nLoginType; if (null != m_BrowserInstance) { m_BrowserInstance.OnToolbarUrlFieldEndEdit(GetWebLoginURL(AdvanceLoginType)); return; } UIMsgCmdData msg = new UIMsgCmdData((int)WndMsgID.WND_MSG_CREATEHERO_WEBBROWSER_STATE, 1, "", IntPtr.Zero, 0); UISystem.Instance.SendTargetWndMessage(WndID.WND_ID_LOGIN, WndMsgID.WND_MSG_CREATEHERO_WEBBROWSER_STATE, msg); m_WebBrowserResNode = UISystem.Instance.GetResNode("UI/Widgets/WebBrowser/WebBrowser"); if (m_WebBrowserResNode.IsValid()) { m_BrowserInstance = m_WebBrowserResNode.InstanceMainRes <UBrowser>(); m_BrowserInstance.Width = (int)WebBrowserSize.x; m_BrowserInstance.Height = (int)WebBrowserSize.y; m_BrowserInstance.InitialURL = GetWebLoginURL(AdvanceLoginType); m_BrowserInstance.SetToolbarType(UWebBrowserToolbarWidget.EToolbar.ETB_Close); m_BrowserInstance.GetRectTransform.SetParent(GetAttachParent(), false); m_BrowserInstance.GetRectTransform.anchoredPosition = WebBrowserPosOffset; m_BrowserInstance.OnJsQueryEvent.RemoveListener(OnJSQueryEvent); m_BrowserInstance.OnJsQueryEvent.AddListener(OnJSQueryEvent); m_BrowserInstance.OnDisConnectedEvent.RemoveListener(OnDisConnectedEvent); m_BrowserInstance.OnDisConnectedEvent.AddListener(OnDisConnectedEvent); } }