static int CleanCache(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); GWebView obj = (GWebView)LuaScriptMgr.GetUnityObjectSelf(L, 1, "GWebView"); obj.CleanCache(); return(0); }
static int EvaluatingJavaScript(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); GWebView obj = (GWebView)LuaScriptMgr.GetUnityObjectSelf(L, 1, "GWebView"); string arg0 = LuaScriptMgr.GetLuaString(L, 2); obj.EvaluatingJavaScript(arg0); return(0); }
static int Init(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); GWebView obj = (GWebView)LuaScriptMgr.GetUnityObjectSelf(L, 1, "GWebView"); GameObject arg0 = (GameObject)LuaScriptMgr.GetUnityObject(L, 2, typeof(GameObject)); obj.Init(arg0); return(0); }
static int SetHeaderField(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 3); GWebView obj = (GWebView)LuaScriptMgr.GetUnityObjectSelf(L, 1, "GWebView"); string arg0 = LuaScriptMgr.GetLuaString(L, 2); string arg1 = LuaScriptMgr.GetLuaString(L, 3); obj.SetHeaderField(arg0, arg1); return(0); }
static int set_URL(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); GWebView obj = (GWebView)o; if (obj == null) { LuaTypes types = LuaDLL.lua_type(L, 1); if (types == LuaTypes.LUA_TTABLE) { LuaDLL.luaL_error(L, "unknown member name URL"); } else { LuaDLL.luaL_error(L, "attempt to index URL on a nil value"); } } obj.URL = LuaScriptMgr.GetString(L, 3); return(0); }
static int get_IsRunWindows(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); GWebView obj = (GWebView)o; if (obj == null) { LuaTypes types = LuaDLL.lua_type(L, 1); if (types == LuaTypes.LUA_TTABLE) { LuaDLL.luaL_error(L, "unknown member name IsRunWindows"); } else { LuaDLL.luaL_error(L, "attempt to index IsRunWindows on a nil value"); } } LuaScriptMgr.Push(L, obj.IsRunWindows); return(1); }
//[NoToLua] //[ContextMenu("ClearLuaHandlerLink")] //public void ClearLuaHandlerLink() //{ // _LuaPanelObject = null; //} //Add Callbacks to UI Components in LinkHolder public void RegisterHandler() { if (!_HasRegistered) { GButton[] gBtns; Button[] buttons; Toggle[] toggles; Scrollbar[] scrollbars; InputField[] inputFields; Dropdown[] dropDowns; GNewListBase[] newLists; GNewTabList[] newTabLists; GNewLayoutTable[] newLayoutTables; //GUIAnim[] newUIAnims; GWebView[] newWebViews; GDragablePageView[] dragablePageViews; DG.Tweening.DOTweenAnimation[] newDOTAnims; GScrollWatcher[] scrollWatchers; GSlideButton[] slideBtns; InteractableUIHolder holder = gameObject.GetComponent <InteractableUIHolder>(); if (holder != null) { gBtns = holder.GBtns; buttons = holder.Buttons; toggles = holder.Toggles; scrollbars = holder.Scrollbars; inputFields = holder.InputFields; dropDowns = holder.Dropdowns; //GNewUI newLists = holder.NewLists; newTabLists = holder.NewTabLists; newLayoutTables = holder.NewLayoutTables; //newUIAnims = holder.newUIAnims; newWebViews = holder.newWebViews; dragablePageViews = holder.dragablePageViews; //DOT newDOTAnims = holder.newDOTAnims; scrollWatchers = holder.ScrollDrags; slideBtns = holder.SlideButtons; } else { gBtns = gameObject.GetComponentsInChildren <GButton>(true); buttons = gameObject.GetComponentsInChildren <Button>(true); toggles = gameObject.GetComponentsInChildren <Toggle>(true); scrollbars = gameObject.GetComponentsInChildren <Scrollbar>(true); inputFields = gameObject.GetComponentsInChildren <InputField>(true); dropDowns = gameObject.GetComponentsInChildren <Dropdown>(true); //GNewUI newLists = gameObject.GetComponentsInChildren <GNewListBase>(true); newTabLists = gameObject.GetComponentsInChildren <GNewTabList>(true); newLayoutTables = gameObject.GetComponentsInChildren <GNewLayoutTable>(true); //newUIAnims = gameObject.GetComponentsInChildren<GUIAnim>(true); newWebViews = gameObject.GetComponentsInChildren <GWebView>(true); dragablePageViews = gameObject.GetComponentsInChildren <GDragablePageView>(true); newDOTAnims = gameObject.GetComponentsInChildren <DG.Tweening.DOTweenAnimation>(true); scrollWatchers = gameObject.GetComponentsInChildren <GScrollWatcher>(true); slideBtns = gameObject.GetComponentsInChildren <GSlideButton>(true); } for (int i = 0; i < gBtns.Length; i++) { GButton gbtn = gBtns[i]; gbtn.OnClick = OnClick; if (gbtn.IsProfessionModel) { gbtn.PointerUpHandler = go => { //Debug.LogWarning("OnPointerUp"); CallPanelFunc("OnPointerUp", go.name); }; gbtn.PointerDownHandler = go => { //Debug.LogWarning("OnPointerDown"); CallPanelFunc("OnPointerDown", go.name); }; gbtn.OnPointerEnterHandler = go => { CallPanelFunc("OnPointerEnter", go.name); }; gbtn.OnPointerExitHandler = go => { CallPanelFunc("OnPointerExit", go.name); }; gbtn.OnPointerLongPressHandler = go => { CallPanelFunc("OnPointerLongPress", go.name); }; } } for (int i = 0; i < buttons.Length; i++) { Button btn = buttons[i]; btn.onClick.RemoveAllListeners(); btn.onClick.AddListener(delegate() { OnClick(btn.gameObject); }); } for (int i = 0; i < toggles.Length; i++) { Toggle toggle = toggles[i]; toggle.onValueChanged.RemoveAllListeners(); toggle.onValueChanged.AddListener(delegate(bool ischeck) { OnToggle(toggle.gameObject, ischeck); }); GNewBtnExpress btx = toggle.GetComponent <GNewBtnExpress>(); if (btx) { btx.RegisterToToggle(toggle); } } for (int i = 0; i < scrollbars.Length; i++) { Scrollbar scrollbar = scrollbars[i]; scrollbar.onValueChanged.RemoveAllListeners(); scrollbar.onValueChanged.AddListener(delegate(float value) { OnScroll(scrollbar.gameObject, value); }); } for (int i = 0; i < inputFields.Length; i++) { InputField inputField = inputFields[i]; inputField.onEndEdit.RemoveAllListeners(); inputField.onValueChanged.RemoveAllListeners(); inputField.onEndEdit.AddListener(delegate(string str) { OnEndEdit(inputField.gameObject, str); }); //try to cut out emoji if (inputField.contentType == InputField.ContentType.Standard) { inputField.onValidateInput = OnValidInputdelegate; } //inputField.onValueChanged.AddListener(delegate(string str) //{ // string str_new = Regex.Replace(str, @"\p{Cs}", ""); //屏蔽emoji // if (string.CompareOrdinal(str, str_new) != 0) // { // inputField.text = str_new; // } //}); inputField.onValueChanged.AddListener(delegate(string str) { OnValueChanged(inputField.gameObject, str); }); } for (int i = 0; i < dropDowns.Length; i++) { Dropdown dpd = dropDowns[i]; GNewDropDown gndpd = dpd as GNewDropDown; if (gndpd != null) { gndpd.OnInitItem = this.OnInitItem; } dpd.onValueChanged.RemoveAllListeners(); dpd.onValueChanged.AddListener(index => { OnDropDown(dpd.gameObject, index); }); } //NewUI for (int i = 0; i < newLists.Length; i++) { GNewListBase list = newLists[i]; list.ClickItemCallBack = this.OnSelectItem; //list.PressItemCallBack = this.OnPressItem; //list.ReleaseItemCallBack = this.OnReleaseItem; list.LongPressCallBack = this.OnLongPressItem; list.InitItemCallBack = this.OnInitItem; if (list.HasChildButton) { list.ClickItemButtonCallBack = this.OnSelectItemButton; } } for (int i = 0; i < newTabLists.Length; i++) { GNewTabList list = newTabLists[i]; list.ClickItemCallBack = this.OnTabListSelectItem; list.InitItemCallBack = this.OnTabListInitItem; if (list.HasChildButton) { list.ClickItemButtonCallBack = this.OnSelectItemButton; } list.ClickSubListItemButtonCallBack = this.OnTabSubListItemButton; } for (int i = 0; i < newLayoutTables.Length; i++) { GNewLayoutTable list = newLayoutTables[i]; list.ClickItemCallBack = this.OnSelectItem; list.InitItemCallBack = this.OnInitItem; if (list.HasChildButton) { list.ClickItemButtonCallBack = this.OnSelectItemButton; } } for (int i = 0; i < newWebViews.Length; i++) { GWebView gwv = newWebViews[i]; gwv.OnReceiveMessage = this.OnReceiveWebViewMessage; } for (int i = 0; i < dragablePageViews.Length; i++) { GDragablePageView gdv = dragablePageViews[i]; gdv._PageItemInitCallBack = this.OnInitItem; gdv._ClickPageItemCallBack = this.OnSelectItem; gdv._ClickPageItemButtonCallBack = this.OnSelectItemButton; gdv._PageItemIndexChangeCallBack = this.OnDragablePageIndexChange; } for (int i = 0; i < newDOTAnims.Length; i++) { if (newDOTAnims[i].IsCallLuaOnComplete) { newDOTAnims[i].OnComplete2Lua = this.OnDOTComplete; } } for (int i = 0; i < scrollWatchers.Length; i++) { scrollWatchers[i].SetHandler(OnScrollWithoutFocus); } for (int i = 0; i < slideBtns.Length; i++) { slideBtns[i].OnSlide = this.OnButtonSlide; } _PanelName = this.name; Schedule.SetTag(_PanelName); _HasRegistered = true; } }
//This overrides the callback of a UI Component to a single call public void RegisterSingleObjHandler(GameObject control, int class_type, bool recursion) { if (control == null) { Debug.LogError("Cannot register event since the control object is null!"); return; } System.Type type = WrapClassID.GetClassType(class_type); if (type == typeof(UnityEngine.UI.Button) || type == typeof(GButton)) { GButton gbtn = control.GetComponent <GButton>(); if (gbtn != null) { gbtn.OnClick = OnClick; return; } Button btn = control.GetComponent <Button>(); if (btn != null) { btn.onClick.RemoveAllListeners(); btn.onClick.AddListener(delegate() { OnClick(btn.gameObject); }); } if (recursion) { GButton[] btns = control.GetComponentsInChildren <GButton>(true); for (int i = 0; i < btns.Length; i++) { if (btns[i] != null) { btns[i].OnClick = OnClick; } } } } else if (type == typeof(Toggle)) { if (recursion) { Toggle[] toggles = control.GetComponentsInChildren <Toggle>(true); for (int i = 0; i < toggles.Length; i++) { if (toggles[i] != null) { toggles[i].onValueChanged.RemoveAllListeners(); GameObject go = toggles[i].gameObject; toggles[i].onValueChanged.AddListener(delegate(bool ischeck) { OnToggle(go, ischeck); }); } } } else { Toggle toggle = control.GetComponent <Toggle>(); if (toggle != null) { toggle.onValueChanged.RemoveAllListeners(); toggle.onValueChanged.AddListener(delegate(bool ischeck) { OnToggle(toggle.gameObject, ischeck); }); } } } else if (type == typeof(GNewIOSToggle)) { GNewIOSToggle gTgl = control.GetComponent <GNewIOSToggle>(); if (gTgl != null) { gTgl.OnClick = OnClick; //gTgl.OnValueChanged = OnToggleSpecial; } if (recursion) { GNewIOSToggle[] gToggles = control.GetComponentsInChildren <GNewIOSToggle>(true); for (int i = 0; i < gToggles.Length; i++) { if (gToggles[i] != null) { gToggles[i].OnClick = OnClick; //gToggles[i].OnValueChanged = OnToggleSpecial; } } } } else if (type == typeof(GText)) { // 现在需求中GText不在root上,所以这么处理;其实不太好 GText gtext = control.GetComponentInChildren <GText>(); if (gtext != null) { gtext.OnClick = OnGTextClick; } if (recursion) { GText[] gts = control.GetComponentsInChildren <GText>(true); for (int i = 0; i < gts.Length; i++) { if (gts[i] != null) { gts[i].OnClick = OnGTextClick; } } } } else if (type == typeof(GImageModel)) { GImageModel gim = control.GetComponent <GImageModel>(); if (gim != null) { gim.OnModelClick = OnClick; } if (recursion) { GImageModel[] gims = control.GetComponentsInChildren <GImageModel>(true); for (int i = 0; i < gims.Length; i++) { if (gims[i] != null) { gims[i].OnModelClick = OnClick; } } } } else if (type == typeof(Slider)) { Slider sld = control.GetComponent <Slider>(); if (sld != null) { sld.onValueChanged.AddListener(delegate(float value) { OnSliderChanged(sld.gameObject, value); }); } if (recursion) { Slider[] sliders = control.GetComponentsInChildren <Slider>(true); for (int i = 0; i < sliders.Length; i++) { if (sliders[i] != null) { sliders[i].onValueChanged.AddListener(delegate(float value) { OnSliderChanged(sliders[i].gameObject, value); }); } } } } else if (type == typeof(GScaleScroll)) { GScaleScroll gss = control.GetComponent <GScaleScroll>(); if (gss != null) { gss.onScaleChanged = OnScaleChanged; } if (recursion) { GScaleScroll[] gsss = control.GetComponentsInChildren <GScaleScroll>(true); for (int i = 0; i < gsss.Length; i++) { if (gsss[i] != null) { gsss[i].onScaleChanged = OnScaleChanged; } } } } else if (type == typeof(GBlood)) { GBlood gwv = control.GetComponent <GBlood>(); if (gwv != null) { gwv.OnTweenFinishCallBack = this.OnDOTComplete; } if (recursion) { GBlood[] gwvs = control.GetComponentsInChildren <GBlood>(true); for (int i = 0; i < gwvs.Length; i++) { gwvs[i].OnTweenFinishCallBack = this.OnDOTComplete; } } } else if (type == typeof(GWebView)) { GWebView gwv = control.GetComponent <GWebView>(); if (gwv != null) { gwv.OnReceiveMessage = this.OnReceiveWebViewMessage; } if (recursion) { GWebView[] gwvs = control.GetComponentsInChildren <GWebView>(true); for (int i = 0; i < gwvs.Length; i++) { gwvs[i].OnReceiveMessage = OnReceiveWebViewMessage; } } } else if (type == typeof(GNewListBase)) { GNewListBase list = control.GetComponent <GNewListBase>(); if (list != null) { list.ClickItemCallBack = this.OnSelectItem; //list.PressItemCallBack = this.OnPressItem; //list.ReleaseItemCallBack = this.OnReleaseItem; list.LongPressCallBack = this.OnLongPressItem; list.InitItemCallBack = this.OnInitItem; if (list.HasChildButton) { list.ClickItemButtonCallBack = this.OnSelectItemButton; } } if (recursion) { GNewListBase[] lists = control.GetComponentsInChildren <GNewListBase>(true); for (int i = 0; i < lists.Length; i++) { lists[i].ClickItemCallBack = this.OnSelectItem; lists[i].LongPressCallBack = this.OnLongPressItem; lists[i].InitItemCallBack = this.OnInitItem; if (lists[i].HasChildButton) { lists[i].ClickItemButtonCallBack = this.OnSelectItemButton; } } } } else { // TODO: 将来根据需要自行扩展 HobaDebuger.LogError("<RegisterUIEventHandler>WrapClassID not supported!" + class_type); } }
//Remove Callbacks of UI Components in LinkHolder, seem to be of no use? void RemoveHandler() { if (_HasRegistered) { GButton[] gBtns; Button[] buttons; Toggle[] toggles; Scrollbar[] scrollbars; InputField[] inputFields; Dropdown[] dropDowns; GNewListBase[] newLists; GNewTabList[] newTabLists; GNewLayoutTable[] newLayoutTables; GWebView[] newWebViews; GDragablePageView[] dragablePageViews; DG.Tweening.DOTweenAnimation[] newDOTAnims; GScrollWatcher[] scrollWatchers; GSlideButton[] slideBtns; InteractableUIHolder holder = gameObject.GetComponent <InteractableUIHolder>(); if (holder != null) { gBtns = holder.GBtns; buttons = holder.Buttons; toggles = holder.Toggles; scrollbars = holder.Scrollbars; inputFields = holder.InputFields; dropDowns = holder.Dropdowns; //GNewUI newLists = holder.NewLists; newTabLists = holder.NewTabLists; newLayoutTables = holder.NewLayoutTables; newWebViews = holder.newWebViews; dragablePageViews = holder.dragablePageViews; newDOTAnims = holder.newDOTAnims; scrollWatchers = holder.ScrollDrags; slideBtns = holder.SlideButtons; } else { gBtns = gameObject.GetComponentsInChildren <GButton>(true); buttons = gameObject.GetComponentsInChildren <Button>(true); toggles = gameObject.GetComponentsInChildren <Toggle>(true); scrollbars = gameObject.GetComponentsInChildren <Scrollbar>(true); inputFields = gameObject.GetComponentsInChildren <InputField>(true); dropDowns = gameObject.GetComponentsInChildren <Dropdown>(true); //GNewUI newLists = gameObject.GetComponentsInChildren <GNewListBase>(true); newTabLists = gameObject.GetComponentsInChildren <GNewTabList>(true); newLayoutTables = gameObject.GetComponentsInChildren <GNewLayoutTable>(true); newWebViews = gameObject.GetComponentsInChildren <GWebView>(true); dragablePageViews = gameObject.GetComponentsInChildren <GDragablePageView>(true); newDOTAnims = gameObject.GetComponentsInChildren <DG.Tweening.DOTweenAnimation>(true); scrollWatchers = gameObject.GetComponentsInChildren <GScrollWatcher>(true); slideBtns = gameObject.GetComponentsInChildren <GSlideButton>(true); } for (int i = 0; i < gBtns.Length; i++) { GButton gbtn = gBtns[i]; gbtn.OnClick = null; if (gbtn.IsProfessionModel) { gbtn.PointerUpHandler = null; gbtn.PointerDownHandler = null; gbtn.OnPointerEnterHandler = null; gbtn.OnPointerExitHandler = null; gbtn.OnPointerLongPressHandler = null; } } for (int i = 0; i < buttons.Length; i++) { buttons[i].onClick.RemoveAllListeners(); } for (int i = 0; i < toggles.Length; i++) { toggles[i].onValueChanged.RemoveAllListeners(); } for (int i = 0; i < scrollbars.Length; i++) { scrollbars[i].onValueChanged.RemoveAllListeners(); } for (int i = 0; i < inputFields.Length; i++) { inputFields[i].onEndEdit.RemoveAllListeners(); inputFields[i].onValueChanged.RemoveAllListeners(); } for (int i = 0; i < dropDowns.Length; i++) { GNewDropDown gndpd = dropDowns[i] as GNewDropDown; if (gndpd != null) { gndpd.OnInitItem = null; } dropDowns[i].onValueChanged.RemoveAllListeners(); } //NewUI for (int i = 0; i < newLists.Length; i++) { newLists[i].ClickItemCallBack = null; newLists[i].LongPressCallBack = null; newLists[i].InitItemCallBack = null; newLists[i].ClickItemButtonCallBack = null; } for (int i = 0; i < newTabLists.Length; i++) { GNewTabList list = newTabLists[i]; list.ClickItemCallBack = null; list.InitItemCallBack = null; list.ClickItemButtonCallBack = null; list.ClickSubListItemButtonCallBack = null; } for (int i = 0; i < newLayoutTables.Length; i++) { GNewLayoutTable list = newLayoutTables[i]; list.ClickItemCallBack = null; list.InitItemCallBack = null; list.ClickItemButtonCallBack = null; } for (int i = 0; i < newWebViews.Length; i++) { GWebView gwv = newWebViews[i]; gwv.OnReceiveMessage = null; } for (int i = 0; i < dragablePageViews.Length; i++) { GDragablePageView gdv = dragablePageViews[i]; gdv._PageItemInitCallBack = null; gdv._ClickPageItemCallBack = null; gdv._ClickPageItemButtonCallBack = null; gdv._PageItemIndexChangeCallBack = null; } for (int i = 0; i < newDOTAnims.Length; i++) { if (newDOTAnims[i].IsCallLuaOnComplete) { newDOTAnims[i].OnComplete2Lua = null; } } for (int i = 0; i < scrollWatchers.Length; i++) { scrollWatchers[i].SetHandler(null); } for (int i = 0; i < slideBtns.Length; i++) { slideBtns[i].OnSlide = null; } _HasRegistered = false; } }