//增加按钮事件,这样写非常有好处。 public void AddClick(UIEventListener.VoidDelegate fun) { if (_clickFun == null) { _clickFun = fun; } else { Debug.Log("回调函数为空,无法执行"); } }
//双击 public void AddDoubleClick(UIEventListener.VoidDelegate fun) { if (_doubleClickFun == null) { _doubleClickFun = fun; } else { Debug.Log("回调函数有问题"); Debug.Log("请输入毁掉函数"); } }
public void OnQuestMBOKClicked(GameObject go) { Globals.Instance.EffectSoundMgr.Play("ui/ui_001"); this.CloseQuestMB(); if (this.OnOKClickEvent != null) { this.OnOKClickEvent(go); this.OnOKClickEvent = null; } }
public void Init(FriendInfo info, UIEventListener.VoidDelegate dDelegate) { base.Init(info); var loginDateTime = Utils.ConvertFromJavaTimestamp(info.LastLoginTime); loginLbl.text = Utils.GetTimeUntilNow(loginDateTime); var givenTime = Utils.ConvertFromJavaTimestamp(info.GiveEnergyTime); givenBtnSprite.isEnabled = givenBtn.isEnabled = !Utils.IsSameDay(givenTime, DateTime.Today); givenLis.onClick = dDelegate; delegateCached = dDelegate; }
public void SetJiaruBtnHandler(UIEventListener.VoidDelegate handler, object parameter, string timeOpen, bool isOpen) { UIEventListener listener = UIEventListener.Get(canjiaBtn); listener.onClick = handler; listener.parameter = parameter; canjiaBtn.SetActive(isOpen); timeLabel.text = timeOpen; timeLabel.gameObject.SetActive(!isOpen); }
public static Delegate UIEventListener_VoidDelegate(LuaFunction func) { if (func == null) { UIEventListener.VoidDelegate fn = delegate { }; return(fn); } UIEventListener.VoidDelegate d = (new UIEventListener_VoidDelegate_Event(func)).Call; return(d); }
/// <summary> /// 注册点击事件 /// </summary> /// <param name="go"></param> /// <param name="luaFunc"></param> public static void AddClick(GameObject go, LuaFunction luaFunc) { UIEventListener.VoidDelegate del = (GameObject sender) => { if (luaFunc != null) { luaFunc.Call(sender); } }; LuaFuncToDel.Add(luaFunc, del); UIEventListener.Get(go).onClick += del; }
public static void RemoveGenericMouseUp(UIEventListener.VoidDelegate fun) { if (UICamera.genericEventHandler != null) { UIEventListener e = UIEventListener.Get(UICamera.genericEventHandler); if (e != null) { e.onMouseUp -= fun; } } }
public void Populate(BaseCardData data, UIEventListener.VoidDelegate onClickedDelegate = null, bool allowRecommending = false) { this.data = data; ShowSponsors(null != data as SponsorDataModel); if (activityParent.activeSelf) { titleLabel.text = data.title; global::System.DateTime date = data.ParseDateString(); companyLabel.text = data.company; timeDistanceLabel.text = date.ToString("t", global::System.Globalization.CultureInfo.CreateSpecificCulture("en-us")) + " | " + data.Proximity.ToString("#.##") + " miles"; nid = data.id; costLabel.text = (data.admission_adults <= 0) && (data.admission_children <= 0) ? "FREE" : " $ "; SetCategoryIcon(data.category); SetCardIcon(data.featured); if (null != data.image && !string.IsNullOrEmpty(data.image.serving_url)) { data.StartImageDownload(UpdatePrimaryImage, null); } // Grab a placeholder image during the download. primaryImage.mainTexture = PlaceholderImageManager.Instance.GetRandomImage((int)data.id); UIEventListener myListener = UIEventListener.Get(gameObject); myListener.onClick -= OnSponsorWebsitePressed; if (null != onClickedDelegate) { myListener.onClick -= onClickedDelegate; myListener.onClick += onClickedDelegate; } } else { SponsorDataModel sponsorData = data as SponsorDataModel; sponsorWebURL = sponsorData.website; if (null != sponsorData.image && !string.IsNullOrEmpty(sponsorData.image.serving_url)) { sponsorData.StartImageDownload(UpdatePrimaryImage, null); } // Grab a placeholder image during the download. sponsorImage.mainTexture = PlaceholderImageManager.Instance.GetRandomImage((int)data.id); UIEventListener myListener = UIEventListener.Get(gameObject); // Sponsors have a different onClick myListener.onClick -= onClickedDelegate; myListener.onClick -= OnSponsorWebsitePressed; myListener.onClick += OnSponsorWebsitePressed; } isPopulated = true; }
protected void AddChildElementClickEvent(UIEventListener.VoidDelegate handler, string childName, string rootName = "") { if (string.IsNullOrEmpty(rootName)) { UIEventListener.Get(FindChild(childName)).onClick = handler; } else { UIEventListener.Get(ComponentTool.FindChild(childName, FindChild(rootName))).onClick = handler; } }
static int ShowErrorMsg(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 1) { fogs.proto.msg.ErrorID arg0 = (fogs.proto.msg.ErrorID)LuaScriptMgr.GetNetObject(L, 1, typeof(fogs.proto.msg.ErrorID)); LuaComponent o = CommonFunction.ShowErrorMsg(arg0); LuaScriptMgr.Push(L, o); return(1); } else if (count == 2) { fogs.proto.msg.ErrorID arg0 = (fogs.proto.msg.ErrorID)LuaScriptMgr.GetNetObject(L, 1, typeof(fogs.proto.msg.ErrorID)); Transform arg1 = (Transform)LuaScriptMgr.GetUnityObject(L, 2, typeof(Transform)); LuaComponent o = CommonFunction.ShowErrorMsg(arg0, arg1); LuaScriptMgr.Push(L, o); return(1); } else if (count == 3) { fogs.proto.msg.ErrorID arg0 = (fogs.proto.msg.ErrorID)LuaScriptMgr.GetNetObject(L, 1, typeof(fogs.proto.msg.ErrorID)); Transform arg1 = (Transform)LuaScriptMgr.GetUnityObject(L, 2, typeof(Transform)); UIEventListener.VoidDelegate arg2 = null; LuaTypes funcType3 = LuaDLL.lua_type(L, 3); if (funcType3 != LuaTypes.LUA_TFUNCTION) { arg2 = (UIEventListener.VoidDelegate)LuaScriptMgr.GetNetObject(L, 3, typeof(UIEventListener.VoidDelegate)); } else { LuaFunction func = LuaScriptMgr.GetLuaFunction(L, 3); arg2 = (param0) => { int top = func.BeginPCall(); LuaScriptMgr.Push(L, param0); func.PCall(top, 1); func.EndPCall(top); }; } LuaComponent o = CommonFunction.ShowErrorMsg(arg0, arg1, arg2); LuaScriptMgr.Push(L, o); return(1); } else { LuaDLL.luaL_error(L, "invalid arguments to method: CommonFunction.ShowErrorMsg"); } return(0); }
public void RegiterBtn(Transform obj, string path, UIEventListener.VoidDelegate voidDelegate) { if (!string.IsNullOrEmpty(path) && obj != null) { obj = obj.Find(path); } if (obj == null) { return; } UIEventListener.Get(obj.gameObject).onClick = voidDelegate; }
public static Delegate UIEventListener_VoidDelegate(LuaFunction func) { UIEventListener.VoidDelegate d = (param0) => { int top = func.BeginPCall(); IntPtr L = func.GetLuaState(); LuaScriptMgr.Push(L, param0); func.PCall(top, 1); func.EndPCall(top); }; return(d); }
public static UIEventListener.VoidDelegate AddMouseUp(GameObject go, Action <object> handler, object arg = null) { if (arg == null) { arg = go; } UIEventListener.VoidDelegate de = delegate(GameObject go1) { handler.DynamicInvoke(arg); }; UIEventListener.Get(go).onMouseUp = de; return(de); }
/// <summary> /// 带参数的OnClick事件 /// </summary> /// <param name="func"></param> /// <returns></returns> public static UIEventListener.VoidDelegate OnClickWithLuaTable(LuaFunction func, LuaTable luaTable) { if (func == null) { return(null); } UIEventListener.VoidDelegate action = (go) => { func.Call(go, luaTable); }; return(action); }
// 用于接收NGUI处理的输入事件 #if USE_NGUI public void registeBoxColliderNGUI(txNGUIObject obj, UIEventListener.VoidDelegate clickCallback, UIEventListener.BoolDelegate pressCallback = null, UIEventListener.BoolDelegate hoverCallback = null) { if (obj.getCollider() == null) { logInfo("window must has box collider that can registeBoxColliderNGUI!"); return; } obj.setClickCallback(clickCallback); obj.setPressCallback(pressCallback); obj.setHoverCallback(hoverCallback); }
/// <summary> /// OnDrag事件 /// </summary> /// <param name="func"></param> /// <returns></returns> public static UIEventListener.VoidDelegate OnDragStart(LuaFunction func) { if (func == null) { return(null); } UIEventListener.VoidDelegate action = (go) => { func.Call(go); }; return(action); }
public void ShowMessageBox(string msg, string centerStr, UIEventListener.VoidDelegate callBack) { UIBaseWindow msgWindow = ReadyToShowBaseWindow(WindowID.WindowID_MessageBox); if (msgWindow != null) { UIMessageBox messageBoxWindow = ((UIMessageBox)msgWindow); ((UIMessageBox)msgWindow).ResetWindow(); messageBoxWindow.SetMsg(msg); messageBoxWindow.SetCenterBtnCallBack(centerStr, callBack); RealShowWindow(msgWindow, WindowID.WindowID_MessageBox); } }
private void AddEventToDeleget(List <string> eventNameList, UIEventListener.VoidDelegate on) { if (eventNameList != null && on != null) { on += (go) => { eventNameList.ForEach((eventName) => { EventDispatcher.TriggerEvent(eventName); }); }; } }
public void ShowMessageBox(string msg, string centerStr, UIEventListener.VoidDelegate callBack) { BaseUI msgWindow = GetUIByType(E_UIType.PanelMessageBox); if (msgWindow != null) { UIMessageBox messageBoxWindow = ((UIMessageBox)msgWindow); ((UIMessageBox)msgWindow).ResetWindow(); messageBoxWindow.SetMsg(msg); messageBoxWindow.SetCenterBtnCallBack(centerStr, callBack); ShowUI(E_UIType.PanelMessageBox, typeof(UIMessageBox), null); } }
static int ShowPopupMsg(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 6); string arg0 = LuaScriptMgr.GetLuaString(L, 1); Transform arg1 = (Transform)LuaScriptMgr.GetUnityObject(L, 2, typeof(Transform)); UIEventListener.VoidDelegate arg2 = null; LuaTypes funcType3 = LuaDLL.lua_type(L, 3); if (funcType3 != LuaTypes.LUA_TFUNCTION) { arg2 = (UIEventListener.VoidDelegate)LuaScriptMgr.GetNetObject(L, 3, typeof(UIEventListener.VoidDelegate)); } else { LuaFunction func = LuaScriptMgr.GetLuaFunction(L, 3); arg2 = (param0) => { int top = func.BeginPCall(); LuaScriptMgr.Push(L, param0); func.PCall(top, 1); func.EndPCall(top); }; } UIEventListener.VoidDelegate arg3 = null; LuaTypes funcType4 = LuaDLL.lua_type(L, 4); if (funcType4 != LuaTypes.LUA_TFUNCTION) { arg3 = (UIEventListener.VoidDelegate)LuaScriptMgr.GetNetObject(L, 4, typeof(UIEventListener.VoidDelegate)); } else { LuaFunction func = LuaScriptMgr.GetLuaFunction(L, 4); arg3 = (param0) => { int top = func.BeginPCall(); LuaScriptMgr.Push(L, param0); func.PCall(top, 1); func.EndPCall(top); }; } string arg4 = LuaScriptMgr.GetLuaString(L, 5); string arg5 = LuaScriptMgr.GetLuaString(L, 6); LuaComponent o = CommonFunction.ShowPopupMsg(arg0, arg1, arg2, arg3, arg4, arg5); LuaScriptMgr.Push(L, o); return(1); }
public void ShowMessageBox(string msg, string leftStr, UIEventListener.VoidDelegate leftCallBack, string rightStr, UIEventListener.VoidDelegate rightCallBack) { UIBaseWindow msgWindow = ReadyToShowBaseWindow(WindowID.WindowID_MessageBox); if (msgWindow != null) { UIMessageBox messageBoxWindow = ((UIMessageBox)msgWindow); ((UIMessageBox)msgWindow).ResetWindow(); messageBoxWindow.SetMsg(msg); messageBoxWindow.SetRightBtnCallBack(rightStr, rightCallBack); messageBoxWindow.SetLeftBtnCallBack(leftStr, leftCallBack); RealShowWindow(msgWindow, WindowID.WindowID_MessageBox); } }
public void SetRightBtnCallBack(string msg, UIEventListener.VoidDelegate callBack) { lbRight.text = msg; NGUITools.SetActive(btnRight, true); UIEventListener.Get(btnRight).onClick = (go) => { if (callBack != null) { callBack(go); } UIMgr.Instance.HideUI(E_UIType.PanelMessageBox); }; }
void Awake() { _itemGrid = transform.FindChild("itemGrid").GetComponent <UIGrid>(); _diamondCostLabel = transform.FindChild("total/diamondNum").GetComponent <UILabel>(); //_goldCostLabel = transform.FindChild("total").FindChild("goldNum").GetComponent<UILabel>(); _buyButton = transform.FindChild("buy").GetComponent <UIButton>(); UIEventListener.Get(_buyButton.gameObject).onClick = buyClick; _voidBuyYes = BuyYes; _voidBuyNo = BuyNo; }
public void ShowMessageBox(string msg, string leftStr, UIEventListener.VoidDelegate leftCallBack, string rightStr, UIEventListener.VoidDelegate rightCallBack) { BaseUI msgWindow = GetUIByType(E_UIType.PanelMessageBox); if (msgWindow != null) { UIMessageBox messageBoxWindow = ((UIMessageBox)msgWindow); ((UIMessageBox)msgWindow).ResetWindow(); messageBoxWindow.SetMsg(msg); messageBoxWindow.SetRightBtnCallBack(rightStr, rightCallBack); messageBoxWindow.SetLeftBtnCallBack(leftStr, leftCallBack); ShowUI(E_UIType.PanelMessageBox, typeof(UIMessageBox), null); } }
public static GameObject SetUIEventListener(GameObject parent, string path, UIEventListener.VoidDelegate onClick) { GameObject go = null; if (parent != null) { go = parent.FindChild(path); if (go == null) { go = parent; } UIEventListener.Get(go).onClick = onClick; } return(go); }
/// <summary> /// 设置按钮委托事件. /// </summary> /// <param name="varParent"></param> /// <param name="varBtnPath"></param> /// <param name="varDelegate"></param> public static void SetButtonEvent(Transform varParent, string varBtnPath, UIEventListener.VoidDelegate varDelegate) { if (varParent != null) { Transform tempBtn = varParent.Find(varBtnPath); if (tempBtn == null) { #if UNITY_EDITOR Debug.LogError("!!ERROR SetButtonEvent Not attach Delegate Named : " + varDelegate.Method.Name); #endif return; } SetButtonEvent(tempBtn, varDelegate); } }
private LuaComponent PopPauseDlg(Transform parent, UIEventListener.VoidDelegate outClick, UIEventListener.VoidDelegate continueClick) { GameObject go = ResourceLoadManager.Instance.LoadPrefab("Prefab/GUI/UIPause") as GameObject; GameObject go_clone = CommonFunction.InstantiateObject(go, parent); go_clone.transform.localPosition = go_clone.transform.localPosition; LuaComponent popup_message = go_clone.GetComponent <LuaComponent>(); popup_message.table.Set("outClicked", outClick); popup_message.table.Set("continueClicked", continueClick); NGUITools.BringForward(go_clone); return(popup_message); }
static int VoidDelegate(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); LuaFunction arg0 = ToLua.CheckLuaFunction(L, 1); UIEventListener.VoidDelegate o = LuaFramework.LuaHelper.VoidDelegate(arg0); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public static void TryRegistOnClick(this GameObject go, UIEventListener.VoidDelegate action, bool isAddUp = false) { if (go == null) { return; } if (isAddUp) { UIEventListener.Get(go).onClick += action; } else { UIEventListener.Get(go).onClick = action; } }
public static LuaComponent ShowErrorMsg(ErrorID code, Transform parent, UIEventListener.VoidDelegate onOKClick) { string message = ErrorMessage.Instance.GetMessage(code); if (message == null || message == string.Empty) { message = string.Format(CommonFunction.GetConstString(code.ToString()), code); } if (parent == null) { parent = UIManager.Instance.m_uiRootBasePanel.transform; } return(ShowPopupMsg(message, parent, onOKClick, null, CommonFunction.GetConstString("BUTTON_OK"), "")); }
private void OnBoxClick(GameObject go) { GTAudioManager.Instance.PlayEffectAudio(GTAudioKey.SOUND_UI_CLICK); int index = go.name.ToInt32() - 1; DCopyMainChapter db = ReadCfgCopyMainChapter.GetDataById(chapter); GTWindowManager.Instance.OpenWindow(EWindowID.UIAwardBox); UIAwardBox window = (UIAwardBox)GTWindowManager.Instance.GetWindow(EWindowID.UIAwardBox); ERewardState state = MLRaid.Instance.GetChapterRewardStateByAwardIndex(chapter, index); UIEventListener.VoidDelegate doReceive = delegate(GameObject w) { GTNetworkSend.Instance.TryMainCopyReceiveReward(chapter, index); }; window.ShowAwardById(db.Awards[index], state, doReceive); }
private void OnBoxClick(GameObject go) { GTAudioManager.Instance.PlayEffectAudio(GTAudioKey.SOUND_UI_CLICK); int index = go.name.ToInt32() - 1; DWorld db = ReadCfgWorld.GetDataById(mChapter); GTWindowManager.Instance.OpenWindow(EWindowID.UIAwardBox); UIAwardBox window = (UIAwardBox)GTWindowManager.Instance.GetWindow(EWindowID.UIAwardBox); int state = RaidModule.Instance.GetChapterRewardStateByAwardIndex(mChapter, index); UIEventListener.VoidDelegate doReceive = delegate(GameObject w) { RaidService.Instance.TryReceiveReward(mCurCopyType, mChapter, index); }; window.ShowAwardById(db.Awards[index], state, doReceive); }
public override void InitPopUp(ItemInfo info, GUIAwakeItemInfoPopUp.EOpenType type, UIEventListener.VoidDelegate cb) { if (info == null) { return; } this.mItemInfo = info; this.OnEquipClickEvent = cb; CommonIconItem.Create(this.mInfoLayer, new Vector3(-150f, 160f, 0f), null, false, 0.9f, null).Refresh(this.mItemInfo, false, false, false); this.mName.text = info.Name; this.mName.color = Tools.GetItemQualityColor(info.Quality); this.mAtts.text = this.GetItemAtt(info); this.mValues.text = this.GetItemAttValue(info); this.mDesc.text = info.Desc; this.SwitchType(type, true); this.Refresh(); }
static int get_onSubmit(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UIEventListener obj = (UIEventListener)o; UIEventListener.VoidDelegate ret = obj.onSubmit; ToLua.Push(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index onSubmit on a nil value")); } }
/// <summary> /// Show a series of text, and execute a function finally. /// </summary> /// <param name="textNeedToShow">a series of text</param> /// <param name="onClick">function executed finally</param> public void ShowAPeriodInfos(List<string> textNeedToShow, UIEventListener.VoidDelegate onClick) { ClearAll(); if (textNeedToShow != null) { showStringList = textNeedToShow; currentIndex = 0; textLabel.text = showStringList[currentIndex]; lastClickDelegate = onClick; } else { showStringList = null; currentIndex = 0; lastClickDelegate = onClick; lastClickDelegate(new GameObject()); } }
/// <summary> /// Clear all showing, remain to show text and VoidDelegate. /// </summary> public void ClearAll() { textLabel.text = null; showStringList = new List<string>(); lastClickDelegate = null; }
public void OnBackClicked(GameObject go) { Globals.Instance.EffectSoundMgr.Play("ui/ui_002"); if (this.BackClickListener != null) { UIEventListener.VoidDelegate backClickListener = this.BackClickListener; this.BackClickListener = null; backClickListener(go); return; } GameUIManager.mInstance.GobackSession(); }
public void Init(int dayIndex, int width, int height, float cardPadding, UIEventListener.VoidDelegate onClickDelegate, int carouselLength = -1, bool clearOnRepopulate = true, bool verticalMode = false, bool allowRecommending = false) { _verticalMode = verticalMode; _allowRecommending = allowRecommending; _clearOnRepopulate = clearOnRepopulate; _onClickDelegate = onClickDelegate; if (!_isConfigured) Configure(); _carouselLength = carouselLength > 0 ? carouselLength : _carouselLength; _carouselLengthMax = _carouselLength; DayIndex = dayIndex; ScrollView.movement = _verticalMode ? UIScrollView.Movement.Vertical : UIScrollView.Movement.Horizontal; ScrollView.onDragStarted -= OnScrollViewDragStarted; ScrollView.onDragStarted += OnScrollViewDragStarted; ScrollView.onDragFinished -= OnScrollViewDragFinished; ScrollView.onDragFinished += OnScrollViewDragFinished; ScrollView.panel.SetRect(0, 0, width, height); ScrollView.panel.depth = 1; if (!_verticalMode) { // Fix issue where dragging isn't 1:1 ScrollView.dragEffect = UIScrollView.DragEffect.None; } else { // Don't center for vertical lists CenterOnChild.enabled = false; } ScrollView.panel.clipping = _verticalMode ? UIDrawCall.Clipping.SoftClip : UIDrawCall.Clipping.None; _cardPadding = cardPadding; _onCardClickedDelegate = onClickDelegate; if (null == _carouselCards) _carouselCards = new List<IActivityViewModelBase>(); if (_carouselCards.Count == 0) { //CreateCards(_carouselLengthMax); if (!_verticalMode) { CenterOnChild.Recenter(); CenterOnChild.enabled = false; //We handle centering so don't do it yourself, CenterOnChild. } else { CreateCards(_carouselLengthMax); ScrollView.ResetPosition(); } } }
public void Hide() { NGUITools.SetActive(base.gameObject, false); this.BackClickListener = null; }
public void RemoveClick() { _clickFun = null; }