//void OnHover(bool isOver) { if (onHover != null) onHover(gameObject, isOver); } void OnPress(bool isPressed) { if (onPress != null) { if (isPressed) { if (currentWidget != null) { currentWidget.SetActive("gaoguang", false); } } currentWidget = this; onPress(gameObject, isPressed); if (isPressed) { currentWidget.SetActive("gaoguang", true); } } }
public void RemoveButtonListener(UIEventListener.VoidDelegate callback) { for (int i = 0; i < Variables.Count; i++) { PrefabVariable variable = Variables[i]; if (variable.Value != null && (variable.Value is UIButton || variable.Value is UIToggle)) { UIWidgetContainer button = variable.Value as UIToggle; if (button == null) { button = variable.Value as UIButton; } if (button == null) { continue; } UIEventListener listener = UIEventListener.Get(button.gameObject); listener.onClick -= callback; } } }
private void initView() { btn_close = NGUITools.FindInChild <Button>(alertViewGameObject, "view/btn_close"); btn_comfirm = NGUITools.FindInChild <Button>(alertViewGameObject, "view/btn_comfirm"); icon = NGUITools.FindInChild <Transform>(alertViewGameObject, "view/topleft"); unitPriceIcon = NGUITools.FindInChild <Transform>(alertViewGameObject, "view/unitPrice"); currencryPriceIcon = NGUITools.FindInChild <Transform>(alertViewGameObject, "view/costPrice"); countValueInput = NGUITools.FindInChild <UIWidgetContainer>(alertViewGameObject, "view/input"); nameLabel = NGUITools.FindInChild <UILabel>(alertViewGameObject, "view/nameLabel"); levelLabel = NGUITools.FindInChild <UILabel>(alertViewGameObject, "view/levelLabel"); levelValueLabel = NGUITools.FindInChild <UILabel>(alertViewGameObject, "view/levelValueLabel"); descriptionLabel = NGUITools.FindInChild <UILabel>(alertViewGameObject, "view/descriptionLabel"); priceLabel = NGUITools.FindInChild <UILabel>(alertViewGameObject, "view/priceLabel"); priceValueLabel = NGUITools.FindInChild <UILabel>(alertViewGameObject, "view/priceValueLabel"); countLabel = NGUITools.FindInChild <UILabel>(alertViewGameObject, "view/countLabel"); countValueLabel = NGUITools.FindInChild <UILabel>(alertViewGameObject, "view/input/countValueLabel"); goldLabel = NGUITools.FindInChild <UILabel>(alertViewGameObject, "view/goldLabel"); goldValueLabel = NGUITools.FindInChild <UILabel>(alertViewGameObject, "view/goldValueLabel"); alterViewTP = NGUITools.FindInChild <TweenPlay>(alertViewGameObject, "view"); }
public void RemoveWidgetContainerEvent(GameObject go) { if (go == null) { return; } UIWidgetContainer component = go.GetComponent <UIWidgetContainer>(); if (component == null) { return; } LuaFunction luaFunction = null; if (this.widgetContainers.TryGetValue(component, out luaFunction)) { luaFunction.Dispose(); luaFunction = null; if (component is UIPopupList) { UIPopupList uIPopupList = component as UIPopupList; uIPopupList.onChange.Clear(); } else if (component is UIProgressBar) { UIProgressBar uIProgressBar = component as UIProgressBar; uIProgressBar.onChange.Clear(); } else if (component is UIToggle) { UIToggle uIToggle = component as UIToggle; uIToggle.onChange.Clear(); } this.widgetContainers.Remove(component); } }
//显示奖品说明 private void ShowRewardTips(GameObject go) { UIWidgetContainer currentItem = go.GetComponent <UIWidgetContainer>(); int itemIndex; for (itemIndex = 0; itemIndex < itemList.Count; itemIndex++) { if (itemList[itemIndex].Equals(currentItem)) { break; } } if (itemIndex >= itemList.Count) { return; } RewardItem item = Singleton <LotteryMode> .Instance.LotteryData[lotteryId].RewardList[itemIndex]; SysItemVo goodsVo = BaseDataMgr.instance.getGoodsVo((uint)item.RewardId); Singleton <TipsManager> .Instance.OpenTipsByGoodsId((uint)item.RewardId, null, null, string.Empty, string.Empty); }
/// <summary> /// 设置当前被指引的对象 /// </summary> /// <param name="currentGuideToggle">当前被指引对象</param> /// <param name="clickCallback">点击后的回调事件</param> protected void SetCurrentGuideToggle(UIToggle currentGuideToggle, EventDelegate.Callback clickCallback) { CurrentGuideButton = currentGuideToggle; EventDelegate.Add(currentGuideToggle.onChange, clickCallback); }
/// <summary> /// 确保goodsId是存在的,0表示锁的icon ,1表示空白 /// </summary> /// <param name="item"></param> /// <param name="goodsId"></param> /// <param name="type"></param> public void InitItem(UIWidgetContainer item, uint goodsId, ItemType type) { UISprite sprite; int color = 1; //默认为 空白 1 string spriteName = string.Empty; UIAtlas atlas = null; //背景 //高光 //InitSpriteHelp(item, "gaoguang", "common", "gaoguang"); InitSpriteHelp(item, "border", string.Empty, string.Empty); if (goodsId == this.LOCK_ICON) //icon 锁 { InitSpriteHelp(item, "background", "common", "pz_1"); InitSpriteHelp(item, "icon", "common", "suo23"); } else if (goodsId == this.EMPTY_ICON) //空格子 { InitSpriteHelp(item, "background", "common", "pz_1"); InitSpriteHelp(item, "icon", "common", "pzkong"); } else if (goodsId == this.ADD_ICON) { InitSpriteHelp(item, "background", "common", "pz_1"); InitSpriteHelp(item, "icon", "common", "add"); } else if (goodsId > 100000) //物品道具 { SysItemVo vo = BaseDataMgr.instance.GetDataById <SysItemVo>(goodsId); color = vo.color; spriteName = string.Empty + vo.icon; if (vo.type == GoodsConst.SMELT_GOODS) { atlas = Singleton <AtlasManager> .Instance.GetAtlas("GemIcon"); } else { atlas = Singleton <AtlasManager> .Instance.GetAtlas("PropIcon"); } if (atlas == null || atlas.GetSprite(spriteName) == null) { spriteName = "100000"; } item.gameObject.SetChildActive("color", false); InitSpriteHelp(item, "icon", atlas, spriteName); InitSpriteHelp(item, "background", "common", "pz_" + color); } else //装备 { SysEquipVo vo = BaseDataMgr.instance.GetDataById <SysEquipVo>(goodsId); color = vo.color; spriteName = string.Empty + vo.icon; atlas = Singleton <AtlasManager> .Instance.GetAtlas("EquipIcon"); if (atlas.GetSprite(spriteName) == null) { InitSpriteHelp(item, "icon", "PropIcon", "100000"); } else { InitSpriteHelp(item, "icon", "EquipIcon", spriteName); } InitSpriteHelp(item, "background", "EquipIcon", "pz_" + color); item.gameObject.SetChildActive("color", false); } }
public UIWidgetContainerMessage(UIWidgetContainer uiWidgetContainer) : base(uiWidgetContainer) { }
public void Init(GameObject obj) { gameObject = obj; obj.SetActive(false); name = NGUITools.FindInChild <UILabel>(gameObject, "info/name"); CloseButton = NGUITools.FindInChild <Button>(gameObject, "close"); CloseButton.onClick = OnCloseClick; skill = NGUITools.FindInChild <UIToggle>(gameObject, "info/function/skill"); skill.onStateChange = OnStateChange; property = NGUITools.FindInChild <UIToggle>(gameObject, "info/function/property"); property.onStateChange = OnStateChange; exp = NGUITools.FindInChild <UIToggle>(gameObject, "info/function/exp"); exp.onStateChange = OnStateChange; skillObj = NGUITools.FindChild(gameObject, "skill"); propetyObj = NGUITools.FindChild(gameObject, "property"); expObj = NGUITools.FindChild(gameObject, "exp"); skillPlay = NGUITools.FindInChild <TweenPlay>(skillObj, ""); propertyPlay = NGUITools.FindInChild <TweenPlay>(propetyObj, ""); expPlay = NGUITools.FindInChild <TweenPlay>(expObj, ""); equipObjs = new List <GameObject>(); GameObject equip = NGUITools.FindChild(gameObject, "info/equips/1"); NGUITools.FindInChild <Button>(equip, "").onClick = OnEquipClick; equipObjs.Add(equip); equip = NGUITools.FindChild(gameObject, "info/equips/2"); NGUITools.FindInChild <Button>(equip, "").onClick = OnEquipClick; equipObjs.Add(equip); equip = NGUITools.FindChild(gameObject, "info/equips/3"); NGUITools.FindInChild <Button>(equip, "").onClick = OnEquipClick; equipObjs.Add(equip); equip = NGUITools.FindChild(gameObject, "info/equips/4"); NGUITools.FindInChild <Button>(equip, "").onClick = OnEquipClick; equipObjs.Add(equip); equip = NGUITools.FindChild(gameObject, "info/equips/5"); NGUITools.FindInChild <Button>(equip, "").onClick = OnEquipClick; equipObjs.Add(equip); equip = NGUITools.FindChild(gameObject, "info/equips/6"); NGUITools.FindInChild <Button>(equip, "").onClick = OnEquipClick; equipObjs.Add(equip); GuideEquipButton = NGUITools.FindChild(gameObject, "info/equips/1").GetComponent <Button>(); foreach (GameObject equipObj in equipObjs) { UISprite sprite = NGUITools.FindInChild <UISprite>(equipObj, "bicn"); sprite.atlas = Singleton <PetView> .Instance.EquipAltas; sprite.normalAtlas = Singleton <PetView> .Instance.EquipAltas; sprite.grayAtlas = Singleton <PetView> .Instance.EquipAltas_Gray; NGUITools.FindInChild <UISprite>(equipObj, "icn").atlas = Singleton <PetView> .Instance.EquipAltas; NGUITools.FindChild(equipObj, "icn").SetActive(false); NGUITools.FindInChild <UISprite>(equipObj, "tipicn").atlas = Singleton <PetView> .Instance.EquipAltas; } EventDelegate.Add(NGUITools.FindInChild <TweenPlay>(equipObjs[5], "icn").onFinished, PlayEquipsFinish); stars = new List <UISprite>(); UISprite star1 = NGUITools.FindInChild <UISprite>(gameObject, "info/stars/1"); UISprite star2 = NGUITools.FindInChild <UISprite>(gameObject, "info/stars/2"); UISprite star3 = NGUITools.FindInChild <UISprite>(gameObject, "info/stars/3"); UISprite star4 = NGUITools.FindInChild <UISprite>(gameObject, "info/stars/4"); UISprite star5 = NGUITools.FindInChild <UISprite>(gameObject, "info/stars/5"); stars.Add(star1); stars.Add(star2); stars.Add(star3); stars.Add(star4); stars.Add(star5); currentPPet = null; FightButton = NGUITools.FindInChild <Button>(gameObject, "info/function/fight"); FightButton.onClick = OnFightClick; NGUITools.FindInChild <Button>(gameObject, "info/function/evolve").onClick = OnEvolveClick; NGUITools.FindInChild <Button>(gameObject, "info/function/upgrade").onClick = OnUpgradeClick; skillObjs = new List <GameObject>(); skillObjs.Add(NGUITools.FindChild(gameObject, "skill/1")); skillObjs.Add(NGUITools.FindChild(gameObject, "skill/2")); skillObjs.Add(NGUITools.FindChild(gameObject, "skill/3")); skillObjs.Add(NGUITools.FindChild(gameObject, "skill/4")); GuideSkillButton = NGUITools.FindChild(gameObject, "skill/1/add").GetComponent <Button>(); foreach (GameObject sobj in skillObjs) { NGUITools.FindInChild <UIWidgetContainer>(sobj, "").onPress = OnSkillPress; } skillObjs.Add(NGUITools.FindChild(gameObject, "skill/5")); skillTips = NGUITools.FindChild(Singleton <PetView> .Instance.gameObject, "tips/skilltips"); petTips = NGUITools.FindChild(Singleton <PetView> .Instance.gameObject, "tips/labeltips"); equipTip = NGUITools.FindChild(gameObject, "info/equips/tips"); equipTipPlay = equipTip.GetComponent <TweenPlay>(); light = NGUITools.FindChild(gameObject, "info/light"); light.SetActive(false); NGUITools.FindInChild <Button>(skillObj, "add").onClick = OnAddSkillPointClick; NGUITools.FindInChild <Button>(gameObject, "info/stone/add").onClick = OnAddStoneClick; expObjs = new List <GameObject>(); expObjs.Add(NGUITools.FindChild(expObj, "1")); expObjs.Add(NGUITools.FindChild(expObj, "2")); expObjs.Add(NGUITools.FindChild(expObj, "3")); expObjs.Add(NGUITools.FindChild(expObj, "4")); expObjs[0].GetComponent <Button>().onClick = OnExpItemClick; expObjs[1].GetComponent <Button>().onClick = OnExpItemClick; expObjs[2].GetComponent <Button>().onClick = OnExpItemClick; expObjs[3].GetComponent <Button>().onClick = OnExpItemClick; NGUITools.FindInChild <UISprite>(expObjs[0], "icn").atlas = Singleton <PetView> .Instance.PropAltas; NGUITools.FindInChild <UISprite>(expObjs[1], "icn").atlas = Singleton <PetView> .Instance.PropAltas; NGUITools.FindInChild <UISprite>(expObjs[2], "icn").atlas = Singleton <PetView> .Instance.PropAltas; NGUITools.FindInChild <UISprite>(expObjs[3], "icn").atlas = Singleton <PetView> .Instance.PropAltas; chose = NGUITools.FindChild(expObj, "chose"); NGUITools.FindInChild <Button>(expObj, "use").onClick = OnUseClick; NGUITools.FindInChild <Button>(expObj, "useten").onClick = OnUseTenClick; NGUITools.FindInChild <UIWidgetContainer>(gameObject, "info/tupian").onDrag = OnPetDrag; SetExpItemInfo(); }