public override void Awake() { base.Awake(); _uiTable = GetComponent<UITable>(); _uiGrid = GetComponent<UIGrid>(); _itemTemplate = gameObject.GetComponent<NguiListItemTemplate>(); }
public CrystalPtPanel(EnDZPlayer playerFlag_) { m_text = new AuxLabel(); m_mpGrid = new UIGrid(); m_playerSide = playerFlag_; m_crystalList = new MList<CrystalPtItem>(); }
public GameObject addDragComponent(GameObject item, UIGrid mGrid, Vector3 itemSize) { GameObject _item = item; //spawn in grid //Debug.Log("====================> bjy: _item:"+_item+"|"+"mGrid:"+mGrid); _item.transform.parent = mGrid.transform; //_item.transform.localScale = Vector3.one; _item.transform.localScale = itemSize; //add drag object _item.AddComponent<UIDragObject>(); _item.GetComponent<UIDragObject>().target = mGrid.transform; _item.GetComponent<UIDragObject>().restrictWithinPanel = true; if ( mGrid.arrangement == UIGrid.Arrangement.Horizontal ) { _item.GetComponent<UIDragObject>().scale = Slide_Horizontal; } else if ( mGrid.arrangement == UIGrid.Arrangement.Vertical ) { _item.GetComponent<UIDragObject>().scale = Slide_Vertical; } //add box collider _item.AddComponent<BoxCollider>(); _item.GetComponent<BoxCollider>().size = itemSize; //add button scale _item.AddComponent<NvUIListItem>(); return _item; }
/// <summary> /// Recenter the draggable list on the center-most child. /// </summary> public void Recenter() { var trans = transform; if (trans.childCount == 0) return; if (uiGrid == null) { uiGrid = GetComponent<UIGrid>(); } if (mScrollView == null) { mScrollView = NGUITools.FindInParents<UIScrollView>(gameObject); if (mScrollView == null) { Debug.LogWarning(GetType() + " requires " + typeof(UIScrollView) + " on a parent object in order to work", this); enabled = false; return; } mScrollView.onDragFinished = OnDragFinished; if (mScrollView.horizontalScrollBar != null) mScrollView.horizontalScrollBar.onDragFinished = OnDragFinished; if (mScrollView.verticalScrollBar != null) mScrollView.verticalScrollBar.onDragFinished = OnDragFinished; } if (mScrollView.panel == null) return; // Calculate the panel's center in world coordinates var corners = mScrollView.panel.worldCorners; var panelCenter = (corners[2] + corners[0]) * 0.5f; // Offset this value by the momentum var pickingPoint = panelCenter - mScrollView.currentMomentum * (mScrollView.momentumAmount * 0.1f); mScrollView.currentMomentum = Vector3.zero; var visibleItems = 0; if (mScrollView.movement == UIScrollView.Movement.Horizontal) { visibleItems = Mathf.FloorToInt(mScrollView.panel.width / uiGrid.cellWidth); } if (mScrollView.movement == UIScrollView.Movement.Vertical) { visibleItems = Mathf.FloorToInt(mScrollView.panel.height / uiGrid.cellHeight); } var maxPerLine = uiGrid.maxPerLine != 0 ? uiGrid.maxPerLine : (uiGrid.arrangement == UIGrid.Arrangement.Horizontal ? Mathf.FloorToInt(mScrollView.panel.width / uiGrid.cellWidth) : Mathf.FloorToInt(mScrollView.panel.height / uiGrid.cellHeight)); if(uiGrid.transform.childCount <= maxPerLine * visibleItems) { return; } var closestPos = visibleItems % 2 == 0 ? FindClosestForEven(pickingPoint, maxPerLine, visibleItems / 2) : FindClosestForOdd(pickingPoint, maxPerLine, visibleItems / 2); CenterOnPos(closestPos); }
public void PrimaryGridBtn(){ GridBase = GetComponent<UIGrid> (); MaxPerLine = GridBase.maxPerLine; DefaultShowIndexs = new int[]{0, 1, 2, 3, 4, 5}; ShowGridBtnObjs = new List<GameObject> (); PrimaryXML (); grids = SeriaOrDeSeria.DeSerialzeXML (path, typeof(GridBtn[])) as GridBtn[]; GridBtnObjs = new GameObject[grids.Length]; for (int i = 0; i < grids.Length; i++) { GameObject ob = Instantiate(GridBtnPrefab) as GameObject; ob.transform.GetChild(0).GetComponent<UITexture>().mainTexture = Resources.Load<Texture>(grids[i].ImgPath); ob.name = GridBtnPrefab.name + i.ToString(); GridBtnObjs[i] = ob; ob.transform.SetParent(DownPanelRepository.transform); ob.transform.position = Vector3.zero; ob.transform.localScale = Vector3.one; } GridBtnObjs[0].GetComponent<MyUIEventIndex>().Listener += Test1; GridBtnObjs[1].GetComponent<MyUIEventIndex>().Listener += Test2; GridBtnObjs[2].GetComponent<MyUIEventIndex>().Listener += Test3; GridBtnObjs[3].GetComponent<MyUIEventIndex>().Listener += Test4; GridBtnObjs[4].GetComponent<MyUIEventIndex>().Listener += Test5; GridBtnObjs[5].GetComponent<MyUIEventIndex>().Listener += Test6; GridBtnObjs[6].GetComponent<MyUIEventIndex>().Listener += Test7; GridBtnObjs[7].GetComponent<MyUIEventIndex>().Listener += Test8; GridBtnObjs[8].GetComponent<MyUIEventIndex>().Listener += Test9; GridBtnObjs[9].GetComponent<MyUIEventIndex>().Listener += Test10; AdjustShowGrids(0, true); }
public static void IntilizationBlocksWaitForSecond(UIGrid grid, int number, GameObject itemPre, List<GameObject> list, float time, float time2, Action<List<GameObject>> callback = null) { for (int i = 0; i < number; i++) { GameObject gameO = (GameObject)GameObject.Instantiate(itemPre); gameO.transform.parent = grid.transform; gameO.transform.localScale = Vector3.one; gameO.transform.localPosition = Vector3.one; gameO.name = i.ToString(); list.Add(gameO); } Utility.instance.WaitForSecs(time, () => { if(grid != null) grid.Reposition(); }); Utility.instance.WaitForSecs(time2, () => { for (int i = 0; i < list.Count; i++) { if (list[i] != null) list[i].SetActive(true); } }); }
public override void OnInit() { base.OnInit(); m_ObjOptionalRoot = FindChild("OptionalRoot"); m_ObjOptionalTemplate = FindChild("OptionalTextureTemplate"); m_OptionalMap = new Dictionary<string, RegularityOptionalElement>(); m_UICamera = WindowManager.Instance.GetUICamera(); m_ObjWinRoot = FindChild("Win"); m_ObjLoseRoot = FindChild("Lose"); m_PopList = FindChildComponent<UIPopupList>("PopupList"); m_ButtonRoot = FindChild("ButtonRoot"); m_Grid = m_ObjOptionalRoot.GetComponent<UIGrid>(); m_LabelLeftTime = FindChildComponent<UILabel>("Label_LeftTime"); m_LabelLeftCount = FindChildComponent<UILabel>("Label_LeftCount"); m_FlowerList = new List<GameObject>(); for (int i = 0; i < 3; ++i) { var obj = FindChild("Flower"+i); m_FlowerList.Add(obj); } AddChildElementClickEvent(OnClickReset, "UIButton_ResetElem"); AddChildElementClickEvent(OnClickResetById, "UIButton_Reset"); AddChildElementClickEvent(OnClickBack, "UIButton_BackElem"); AddChildElementClickEvent(OnClickBack, "UIButton_Back"); AddChildElementClickEvent(OnClickBack, "Button_Exit"); m_ObjLoseRoot.SetActive(false); m_ObjWinRoot.SetActive(false); m_ButtonRoot.SetActive(false); }
public override void OnCreate() { base.OnCreate(); AddChildComponentMouseClick("beginBtn", OnBeginBtnClick); AddChildComponentMouseClick("halllistBtn", OnHalllistBtnClick); AddChildComponentMouseClick("sngBtn", OnSngBtnClick); AddChildComponentMouseClick("mttBtn", OnMttBtnClick); AddChildComponentMouseClick("taskBtn", OnTaskBtnClick); AddChildComponentMouseClick("rechargeBtn", OnRechargeBtnClick); AddChildComponentMouseClick("huodongBtn", OnHuodongBtnClick); AddChildComponentMouseClick("interactBtn", OnInteractBtnClick); AddChildComponentMouseClick("billboardBtn", OnBillboardBtnClick); AddChildComponentMouseClick("faqBtn", OnFaqBtnClick); AddChildComponentMouseClick("settingBtn", OnSettingBtnClick); AddChildComponentMouseClick("girl", OnGirlClick); m_Grid = Utils.FindChild(mUIObject.transform, "Grid"); mGridGrid = m_Grid.GetComponent<UIGrid>(); Transform girlEye = Utils.FindChild(mUIObject.transform, "GirlEye"); m_GirlEyeFrame1 = Utils.FindChild(girlEye, "frame1"); m_GirlEyeFrame2 = Utils.FindChild(girlEye, "frame2"); m_GirlEyeFrame3 = Utils.FindChild(girlEye, "frame3"); Transform girlFace = Utils.FindChild(mUIObject.transform, "GirlFace"); m_FaceRed = Utils.FindChild(girlFace, "faceRed"); m_MouthClose = Utils.FindChild(girlFace, "mouthClose"); m_MouthHalf = Utils.FindChild(girlFace, "mouthHalf"); m_EyeClose = Utils.FindChild(girlFace, "eyeClose"); m_EyeHalf = Utils.FindChild(girlFace, "eyeHalf"); }
// Use this for initialization void Start() { meetingListPage = GameObject.Find("mainPannel").GetComponent<UIPanel>(); grid = meetingListPage.GetComponentInChildren<UIGrid>(); this.initFakeData(); }
private void Awake() { panelCached = ScrollView.GetComponentInChildren<UIPanel>(); gridCached = ScrollView.GetComponentInChildren<UIGrid>(); ScrollView.onDragFinished += OnDragFinished; restrictWithinPanelCached = ScrollView.restrictWithinPanel; }
/// <summary> /// Used to initial some varibles. /// </summary> private void Awake() { okLis = UIEventListener.Get(transform.Find("OK").gameObject); cancelLis = UIEventListener.Get(transform.Find("Cancel").gameObject); costCoins = Utils.FindChild(transform, "CostValue").GetComponent<UILabel>(); grid = GetComponentInChildren<UIGrid>(); }
public void findWidget() { if (EnDZPlayer.ePlayerSelf == m_playerSide) { m_text = new AuxLabel(UtilApi.GoFindChildByPObjAndName(CVSceneDZPath.SelfMpText)); } else { m_text = new AuxLabel(UtilApi.GoFindChildByPObjAndName(CVSceneDZPath.EnemyMpText)); } if (EnDZPlayer.ePlayerSelf == m_playerSide) { m_mpGrid = new UIGrid(); m_mpGrid.setGameObject(UtilApi.GoFindChildByPObjAndName(CVSceneDZPath.SelfMpList)); m_mpGrid.maxPerLine = 1; m_mpGrid.cellWidth = 0.5f; m_mpGrid.cellHeight = 0.5f; } else { m_mpGrid = new UIGrid(); m_mpGrid.setGameObject(UtilApi.GoFindChildByPObjAndName(CVSceneDZPath.EnemyMpList)); m_mpGrid.maxPerLine = 10; m_mpGrid.cellWidth = 0.5f; m_mpGrid.cellHeight = 0.5f; } }
// Use this for initialization void Awake() { mailItems = transform.Find("MailItems").GetComponent<UIGrid>(); okLis = UIEventListener.Get(transform.Find("OK").gameObject); okLis.onClick = OnOk; dimmerLis = UIEventListener.Get(transform.Find("Dimmer").gameObject); dimmerLis.onClick = OnDimmer; }
void Start() { bagGirid = this.FindComponent<UIGrid>(bagGiridPath); bagItemPrefab = Resources.Load(bagItemPath) as GameObject; StartCoroutine(LoadBagItems()); }
void Start() { grid = gameObject.GetComponent<UIGrid>(); Vector3 newPos = new Vector3(Screen.width * relativePosition.x, Screen.height * relativePosition.y, 0f); transform.localPosition = newPos; }
private void Update() { grid = gameObject.GetComponentInParent<UIGrid> (); if (grid) { //dragDropContainer.reparentTarget = grid.transform; } }
// Use this for initialization void Start() { Debug.Log("MeetingList create"); meetingGrid = meetingGridGameObject.GetComponentInChildren<UIGrid>(); //meetingWarningGrid = meetingWarningGridGameObject.GetComponentInChildren<UIGrid>(); destroyChilds(meetingGridGameObject); destroyChilds(meetingWarningGridGameObject); initMeetingData(); }
public MedicApp(int type, SmartPhone phone, int consumeRate, Entity owner = null, string Title = "Medic App v1.0") : base(type, phone, consumeRate, owner, Title) { UIGrid statusEffects = new UIGrid(Width: SmartPhone.SCREEN_RECT.Width, GridColumns: 1, CursorType: CursorType.Cursor, MarginBottom: 20); PageContent.AddElement(statusEffects); PageContent.AddElement(CreateSwitchAppButton("Main Menu", phone.GetMainMenu())); }
private void CreateObjects() { this.mTipBg = base.transform.Find("itemTipBg").GetComponent<UISprite>(); GameObject gameObject = this.mTipBg.transform.Find("closeBtn").gameObject; UIEventListener expr_3C = UIEventListener.Get(gameObject); expr_3C.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(expr_3C.onClick, new UIEventListener.VoidDelegate(this.OnCloseBtnClick)); this.mSchoolName = this.mTipBg.transform.Find("guildName").GetComponent<UILabel>(); this.mItemGrid = this.mTipBg.transform.Find("contents").GetComponent<UIGrid>(); }
public void Init() { if (isInit == true) return; stageIconPrefab = Resources.Load("UI/Pf_Ui_StageIcon") as GameObject; grid = GetComponentInChildren<UIGrid>(); AddItem(); isInit = true; }
void Start() { uiGrid = this.transform.parent.GetComponent<UIGrid>(); EventDelegate.Set(SellButton.onClick, () => { //出售一件装备,需要删除缓存层,需要删除服务器上的数据 OnSellClick(); });//为button添加响应事件 }
// Use this for initialization private void Awake() { selCount = Utils.FindChild(transform, "SelValue").GetComponent<UILabel>(); soulCount = Utils.FindChild(transform, "SoulValue").GetComponent<UILabel>(); scHeroList = HeroModelLocator.Instance.SCHeroList; hero = HeroModelLocator.Instance.HeroTemplates; sellLis = UIEventListener.Get(transform.Find("Button-Sell").gameObject); grid = transform.Find("Container/Grid").GetComponent<UIGrid>(); }
private void CreateObjects() { this.mScrollView = GameUITools.FindGameObject("Panel", base.gameObject).GetComponent<UIScrollView>(); this.mContent = GameUITools.FindGameObject("Content", this.mScrollView.gameObject).GetComponent<UIGrid>(); this.mPass = GameUITools.RegisterClickEvent("Pass", new UIEventListener.VoidDelegate(this.OnPassClick), base.gameObject); this.mCancel = GameUITools.RegisterClickEvent("Cancel", new UIEventListener.VoidDelegate(this.OnCancelClick), base.gameObject); this.mOK = GameUITools.RegisterClickEvent("OK", new UIEventListener.VoidDelegate(this.OnOKClick), base.gameObject); this.mPassCost = GameUITools.FindUILabel("Cost", this.mPass); }
private void Awake() { cardDesPanel = GetComponent<UIPanel>(); cardNameLabel = transform.FindChild("Container/CardInfo/CardName/Value").GetComponent<UILabel>(); cardLevelLabel = transform.FindChild("Container/CardInfo/CardLevel/Value").GetComponent<UILabel>(); cardDamageLabel = transform.FindChild("Container/CardInfo/CardDamage/Value").GetComponent<UILabel>(); cardSpeedLabel = transform.FindChild("Container/CardInfo/CardSpeed/Value").GetComponent<UILabel>(); stateListWidget = transform.FindChild("Container/CardInfo/StateList").GetComponent<UIWidget>(); stateListGrid = transform.FindChild("Container/CardInfo/StateList/List").GetComponent<UIGrid>(); }
void Start () { grid = gridObject.GetComponent<UIGrid>(); foreach (string spriteName in itemSprites) { GameObject go = NGUITools.AddChild(gridObject, itemPrefab); UISprite sprite = go.transform.FindChild("Item").GetComponent<UISprite>(); sprite.spriteName = spriteName; } grid.Reposition(); }
void Awake() { _instance = this; taskListGrid = transform.Find("Scroll View/Grid").GetComponent<UIGrid>(); tween = this.GetComponent<TweenPosition>(); closeButton = transform.Find("CloseButton").GetComponent<UIButton>(); EventDelegate ed = new EventDelegate(this, "OnClose"); closeButton.onClick.Add(ed); }
void Start() { m_Entries = new Dictionary<string, GameObject>(); m_Grid = GetComponent<UIGrid>(); Add(Global.Player().mine); Global.Player().postConnected += ListenPlayerConnected; Global.Ready().postPoll += ListenPollReadyInfo; }
public void TestRemove() { UIGridColumn column = new UIGridColumn("heading", null, null, null, false, 100, PropAlignment.left, null); UIGrid uiGrid = new UIGrid(); uiGrid.Add(column); Assert.IsTrue(uiGrid.Contains(column)); uiGrid.Remove(column); Assert.IsFalse(uiGrid.Contains(column)); }
// Use this for initialization void Start() { btnBack.onClick.Add(new EventDelegate(OnBack)); btnForward.onClick.Add(new EventDelegate(OnForward)); usv = GetComponent<UIScrollView>(); grid = GetComponentInChildren<UIGrid>(); oriPos = transform.localPosition; cellWidth = grid.cellWidth; cellHeigth = grid.cellHeight; Init(); }
/// <summary> /// Awakw this instance. /// </summary> void Awake() { Install(new string[]{ UC_GRID, UC_JOIN, }); Grid = GetChildComponent<UIGrid>(UC_GRID); if (!Grid) throw new System.NullReferenceException(); }
public void SetFrist(yuan.YuanMemoryDB.YuanTable mYt, DelListBack mEvent, int mNum, UIGrid mGrid, List <BtnArena> mListBtns, string btnFunction, BtnGameManager.DegSetBtn degSetBtn, string mName) { this.myGrid = mGrid; this.myListBtns = mListBtns; this.myBtnFunction = btnFunction; this.myDegSetBtn = degSetBtn; this.myName = mName; this.yt = mYt; this.eventListBack = mEvent; this.listNum = mNum; this.maxPage = yt.Count / listNum; if (yt.Count % listNum > 0) { maxPage++; } SetPage(0); }
/// <summary> /// Cache the transform and the panel. /// </summary> void Awake() { mTrans = transform; mPanel = GetComponent <UIPanel>(); mGrid = mPanel.GetComponentInChildren <UIGrid>(); }
/// <summary> /// Drop the item onto the specified object. /// </summary> protected virtual void OnDragDropRelease(GameObject surface) { if (!cloneOnDrag) { // Clear the reference to the scroll view since it might be in another scroll view now var drags = GetComponentsInChildren <UIDragScrollView>(); foreach (var d in drags) { d.scrollView = null; } // Re-enable the collider if (mButton != null) { mButton.isEnabled = true; } else if (mCollider != null) { mCollider.enabled = true; } else if (mCollider2D != null) { mCollider2D.enabled = true; } // Is there a droppable container? UIDragDropContainer container = surface ? NGUITools.FindInParents <UIDragDropContainer>(surface) : null; if (container != null) { // Container found -- parent this object to the container mTrans.parent = (container.reparentTarget != null) ? container.reparentTarget : container.transform; Vector3 pos = mTrans.localPosition; pos.z = 0f; mTrans.localPosition = pos; } else { // No valid container under the mouse -- revert the item's parent mTrans.parent = mParent; } // Update the grid and table references mParent = mTrans.parent; mGrid = NGUITools.FindInParents <UIGrid>(mParent); mTable = NGUITools.FindInParents <UITable>(mParent); // Re-enable the drag scroll view script if (mDragScrollView != null) { Invoke("EnableDragScrollView", 0.001f); } // Notify the widgets that the parent has changed NGUITools.MarkParentAsChanged(gameObject); if (mTable != null) { mTable.repositionNow = true; } if (mGrid != null) { mGrid.repositionNow = true; } } // We're now done OnDragDropEnd(); if (cloneOnDrag) { DestroySelf(); } }
private void OnEvent_DailyBonusUpdate() { ResourceUnit GetMoneyUnit = ResourcesManager.Instance.loadImmediate(GameConstDefine.LoadDailyHeroIcon, ResourceType.PREFAB); UIAtlas uia_hero = (GetMoneyUnit.Asset as GameObject).GetComponent <UIAtlas>(); mMonthInWindow = DailyBonusCtrl.Instance.mMonth; mHadDayInWindow = DailyBonusCtrl.Instance.mHadDay; mTodayCanInWindow = DailyBonusCtrl.Instance.mTodayCan; if (LinkGameObjs != null) { UIEventListener.Get(LinkGameObjs).onClick -= OnDaliyGameObjsClick; LinkGameObjs = null; } LoadUiResource.ClearAllChild(mGrid.transform); DaliyGameObjs.Clear(); for (uint i = 0; i < DailyBonusCtrl.Instance.mMaxDay; ++i) { DailyBonusConfigInfo bonus = ConfigReader.GetDailyBonusInfo(i + 1);// 设置奖励坑位(1.金币 2.钱 3.物品) if (bonus == null) { continue; // 没有奖励不显示 } GameObject addobj = LoadUiResource.AddChildObject(mGrid.transform, GameConstDefine.LoadDailyPrizeUI); addobj.transform.parent = mGrid.transform; addobj.transform.localScale = Vector3.one; addobj.name = (DaliyGameObjs.Count + 1).ToString(); addobj.transform.FindChild("BG/Label").GetComponent <UILabel>().text = "累计签到" + (i + 1).ToString() + "天"; DaliyGameObjs.Add(addobj); string hookname = "Interface/SignInterface/Calendar/Date" + (i + 1).ToString() + "/Hook"; ////////////////////////////////////////////////////////////////////////// if (i < DailyBonusCtrl.Instance.mHadDay) {//已领取 mRoot.FindChild(hookname).GetComponent <UISprite>().gameObject.SetActive(true); addobj.transform.FindChild("Done").GetComponent <UISprite>().gameObject.SetActive(true); addobj.transform.FindChild("NotDone").GetComponent <UISprite>().gameObject.SetActive(false); addobj.transform.FindChild("UnDone").GetComponent <UISprite>().gameObject.SetActive(false); } else if (i == DailyBonusCtrl.Instance.mHadDay) { if (DailyBonusCtrl.Instance.mTodayCan) {//可领取 mRoot.FindChild(hookname).GetComponent <UISprite>().gameObject.SetActive(false); addobj.transform.FindChild("Done").GetComponent <UISprite>().gameObject.SetActive(false); addobj.transform.FindChild("NotDone").GetComponent <UISprite>().gameObject.SetActive(true); addobj.transform.FindChild("UnDone").GetComponent <UISprite>().gameObject.SetActive(false); //LinkGameObjs = addobj.transform.FindChild("NotDone").gameObject; LinkGameObjs = addobj; UIEventListener.Get(LinkGameObjs).onClick += OnDaliyGameObjsClick; } else {//无法领取 mRoot.FindChild(hookname).GetComponent <UISprite>().gameObject.SetActive(false); addobj.transform.FindChild("Done").GetComponent <UISprite>().gameObject.SetActive(false); addobj.transform.FindChild("NotDone").GetComponent <UISprite>().gameObject.SetActive(false); addobj.transform.FindChild("UnDone").GetComponent <UISprite>().gameObject.SetActive(true); } } else {//无法领取 mRoot.FindChild(hookname).GetComponent <UISprite>().gameObject.SetActive(false); addobj.transform.FindChild("Done").GetComponent <UISprite>().gameObject.SetActive(false); addobj.transform.FindChild("NotDone").GetComponent <UISprite>().gameObject.SetActive(false); addobj.transform.FindChild("UnDone").GetComponent <UISprite>().gameObject.SetActive(true); } ////////////////////////////////////////////////////////////////////////// int pos = -1; foreach (string itemStr in bonus.n32ItemID) { ++pos; UIGrid tmpGrid = addobj.transform.FindChild("Grid").GetComponent <UIGrid>(); GameObject oneBouns = LoadUiResource.AddChildObject(tmpGrid.transform, GameConstDefine.LoadDailyOneBonusUI); oneBouns.transform.FindChild("Num").GetComponent <UILabel>().text = "x" + bonus.n32ItemNum[pos]; // 数量 bool isHadExtend = bonus.n32Type[pos] == "2"; //是否有额外奖励 if (isHadExtend) { string starname = "Interface/SignInterface/Calendar/Date" + (i + 1).ToString() + "/Star"; mRoot.FindChild(starname).gameObject.SetActive(true); oneBouns.transform.FindChild("Tip").gameObject.SetActive(true); } UInt32 itemID = Convert.ToUInt32(itemStr);//根据id获取图片id,显示图片和数量和名称 if (itemID == 1) { oneBouns.transform.GetComponent <UISprite>().spriteName = (9).ToString(); oneBouns.transform.FindChild("Name").GetComponent <UILabel>().text = "金币"; } else if (itemID == 2) { oneBouns.transform.GetComponent <UISprite>().spriteName = (10).ToString(); oneBouns.transform.FindChild("Name").GetComponent <UILabel>().text = "钻石"; } else if (itemID > 100000 && itemID < 110000) { oneBouns.transform.GetComponent <UISprite>().atlas = uia_hero; oneBouns.transform.FindChild("Name").GetComponent <UILabel>().text = ConfigReader.HeroBuyXmlInfoDict[(int)itemID].Name; oneBouns.transform.GetComponent <UISprite>().spriteName = ConfigReader.HeroBuyXmlInfoDict[(int)itemID].DefaultIcon; } else if (itemID > 110000 && itemID < 120000) { oneBouns.transform.FindChild("Name").GetComponent <UILabel>().text = "皮肤"; oneBouns.transform.GetComponent <UISprite>().spriteName = ConfigReader.HeroSkinXmlInfoDict[(int)itemID].Icon; } else if (itemID > 120000 && itemID < 130000) { oneBouns.transform.FindChild("Name").GetComponent <UILabel>().text = "符文"; oneBouns.transform.GetComponent <UISprite>().spriteName = ConfigReader.RuneXmlInfoDict[itemID].Icon; } else if (itemID > 130000 && itemID < 140000) { oneBouns.transform.FindChild("Name").GetComponent <UILabel>().text = ConfigReader.OtherItemXmlInfoDic[itemID].sName; oneBouns.transform.GetComponent <UISprite>().spriteName = ConfigReader.OtherItemXmlInfoDic[itemID].icon; } else { oneBouns.transform.FindChild("Name").GetComponent <UILabel>().text = "????"; oneBouns.transform.GetComponent <UISprite>().spriteName = (115).ToString(); Debug.LogError("unknow itemid in daliybouns " + itemStr); } } } for (uint i = DailyBonusCtrl.Instance.mMaxDay; i < 31; ++i) { string lightname = "Interface/SignInterface/Calendar/Date" + (i + 1).ToString() + "/Light"; mRoot.FindChild(lightname).gameObject.SetActive(false); } mGrid.Reposition(); }
public void Recenter() { if (mScrollView == null) { mScrollView = NGUITools.FindInParents <UIScrollView>(gameObject); if (mScrollView == null) { Debug.LogWarning(GetType() + " requires " + typeof(UIScrollView) + " on a parent object in order to work", this); enabled = false; return; } else { if (mScrollView) { mScrollView.centerOnChild = this; //mScrollView.onDragFinished += OnDragFinished; } if (mScrollView.horizontalScrollBar != null) { mScrollView.horizontalScrollBar.onDragFinished += OnDragFinished; } if (mScrollView.verticalScrollBar != null) { mScrollView.verticalScrollBar.onDragFinished += OnDragFinished; } } } if (mScrollView.panel == null) { return; } Transform trans = transform; if (trans.childCount == 0) { return; } // Calculate the panel's center in world coordinates Vector3[] corners = mScrollView.panel.worldCorners; Vector3 panelCenter = (corners[2] + corners[0]) * 0.5f; // Offset this value by the momentum Vector3 momentum = mScrollView.currentMomentum * mScrollView.momentumAmount; Vector3 moveDelta = NGUIMath.SpringDampen(ref momentum, 9f, 2f); Vector3 pickingPoint = panelCenter - moveDelta * 0.01f; // Magic number based on what "feels right" float min = float.MaxValue; Transform closest = null; int index = 0; int ignoredIndex = 0; UIGrid grid = GetComponent <UIGrid>(); List <Transform> list = null; // Determine the closest child if (grid != null) { list = grid.GetChildList(); for (int i = 0, imax = list.Count, ii = 0; i < imax; ++i) { Transform t = list[i]; if (!t.gameObject.activeInHierarchy) { continue; } float sqrDist = Vector3.SqrMagnitude(t.position - pickingPoint); if (sqrDist < min) { min = sqrDist; closest = t; index = i; ignoredIndex = ii; } ++ii; } } else { for (int i = 0, imax = trans.childCount, ii = 0; i < imax; ++i) { Transform t = trans.GetChild(i); if (!t.gameObject.activeInHierarchy) { continue; } float sqrDist = Vector3.SqrMagnitude(t.position - pickingPoint); if (sqrDist < min) { min = sqrDist; closest = t; index = i; ignoredIndex = ii; } ++ii; } } // If we have a touch in progress and the next page threshold set if (nextPageThreshold > 0f && UICamera.currentTouch != null) { // If we're still on the same object if (mCenteredObject != null && mCenteredObject.transform == (list != null ? list[index] : trans.GetChild(index))) { Vector3 totalDelta = UICamera.currentTouch.totalDelta; totalDelta = transform.rotation * totalDelta; float delta = 0f; switch (mScrollView.movement) { case UIScrollView.Movement.Horizontal: { delta = totalDelta.x; break; } case UIScrollView.Movement.Vertical: { delta = -totalDelta.y; break; } default: { delta = totalDelta.magnitude; break; } } if (Mathf.Abs(delta) > nextPageThreshold) { if (delta > nextPageThreshold) { // Next page if (list != null) { if (ignoredIndex > 0) { closest = list[ignoredIndex - 1]; } else { closest = (GetComponent <UIWrapContent>() == null) ? list[0] : list[list.Count - 1]; } } else if (ignoredIndex > 0) { closest = trans.GetChild(ignoredIndex - 1); } else { closest = (GetComponent <UIWrapContent>() == null) ? trans.GetChild(0) : trans.GetChild(trans.childCount - 1); } } else if (delta < -nextPageThreshold) { // Previous page if (list != null) { if (ignoredIndex < list.Count - 1) { closest = list[ignoredIndex + 1]; } else { closest = (GetComponent <UIWrapContent>() == null) ? list[list.Count - 1] : list[0]; } } else if (ignoredIndex < trans.childCount - 1) { closest = trans.GetChild(ignoredIndex + 1); } else { closest = (GetComponent <UIWrapContent>() == null) ? trans.GetChild(trans.childCount - 1) : trans.GetChild(0); } } } } } CenterOn(closest, panelCenter); }
public override void OnInitialize() { Width = (408, 0); Height = (40 + Container.Handler.Slots / 9 * 44, 0); this.Center(); textLabel = new UIText(Container.DisplayName.GetTranslation()) { HAlign = 0.5f }; Append(textLabel); UIButton buttonLootAll = new UIButton(PortableStorage.textureLootAll) { Size = new Vector2(20) }; buttonLootAll.OnClick += (evt, element) => { ItemUtility.LootAll(Container.Handler, Main.LocalPlayer); if (Container.Handler.GetItemInSlot(Container.selectedIndex).IsAir) { Container.SetIndex(-1); } }; buttonLootAll.GetHoverText += () => Language.GetText("LegacyInterface.29").ToString(); Append(buttonLootAll); UIButton buttonDepositAll = new UIButton(PortableStorage.textureDepositAll) { Size = new Vector2(20), Left = (28, 0) }; buttonDepositAll.OnClick += (evt, element) => ItemUtility.DepositAll(Container.Handler, Main.LocalPlayer); buttonDepositAll.GetHoverText += () => Language.GetText("LegacyInterface.30").ToString(); Append(buttonDepositAll); buttonClose = new UITextButton("X") { Size = new Vector2(20), Left = (-20, 1), RenderPanel = false }; buttonClose.OnClick += (evt, element) => BaseLibrary.BaseLibrary.PanelGUI.UI.CloseUI(Container); Append(buttonClose); gridItems = new UIGrid <UIBuilderReserveSlot>(9) { Width = (0, 1), Height = (-28, 1), Top = (28, 0), OverflowHidden = true, ListPadding = 4f }; Append(gridItems); for (int i = 0; i < Container.Handler.Slots; i++) { UIBuilderReserveSlot slot = new UIBuilderReserveSlot(Container, i); gridItems.Add(slot); } } }
public override void OnEnter() { //if an GameObject Reference has been set, create that, otherwise create an Empty GameObject if (!childReference.IsNone && childReference.Value != null) { storeChildInstance.Value = NGUITools.AddChild(parent.Value, childReference.Value); //If name has been set, use that as the name for the created GO, otherwise use the name of the set Reference storeChildInstance.Value.name = !name.IsNone ? name.Value : childReference.Value.gameObject.name; } else { var _go = new GameObject("Empty GameObject"); _go.transform.parent = parent.Value.transform; _go.name = !name.IsNone ? name.Value : _go.gameObject.name; storeChildInstance.Value = _go; storeChildInstance.Value.layer = parent.Value.layer; } if (!position.IsNone) { if (space == Space.Self) { storeChildInstance.Value.transform.localPosition = position.Value; } else { storeChildInstance.Value.transform.position = position.Value; } } if (!rotation.IsNone) { if (space == Space.Self) { storeChildInstance.Value.transform.localRotation = Quaternion.Euler(rotation.Value); } else { storeChildInstance.Value.transform.rotation = Quaternion.Euler(rotation.Value); } } if (!scale.IsNone) { storeChildInstance.Value.transform.localScale = scale.Value; } if (reposition.Value) { UITable mTable = NGUITools.FindInParents <UITable>(storeChildInstance.Value); if (mTable != null) { mTable.repositionNow = true; } UIGrid mGrid = NGUITools.FindInParents <UIGrid>(storeChildInstance.Value); if (mGrid != null) { mGrid.repositionNow = true; } } Finish(); }
public void Recenter() { if (this.mScrollView == null) { this.mScrollView = NGUITools.FindInParents <UIScrollView>(base.gameObject); if (this.mScrollView == null) { Debug.LogWarning(string.Concat(new object[] { base.GetType(), " requires ", typeof(UIScrollView), " on a parent object in order to work" }), this); base.enabled = false; return; } if (this.mScrollView) { this.mScrollView.centerOnChild = this; } if (this.mScrollView.horizontalScrollBar != null) { UIProgressBar horizontalScrollBar = this.mScrollView.horizontalScrollBar; horizontalScrollBar.onDragFinished = (UIProgressBar.OnDragFinished)Delegate.Combine(horizontalScrollBar.onDragFinished, new UIProgressBar.OnDragFinished(this.OnDragFinished)); } if (this.mScrollView.verticalScrollBar != null) { UIProgressBar verticalScrollBar = this.mScrollView.verticalScrollBar; verticalScrollBar.onDragFinished = (UIProgressBar.OnDragFinished)Delegate.Combine(verticalScrollBar.onDragFinished, new UIProgressBar.OnDragFinished(this.OnDragFinished)); } } if (this.mScrollView.panel == null) { return; } Transform transform = base.transform; if (transform.childCount == 0) { return; } Vector3[] worldCorners = this.mScrollView.panel.worldCorners; Vector3 vector = (worldCorners[2] + worldCorners[0]) * 0.5f; Vector3 vector2 = this.mScrollView.currentMomentum * this.mScrollView.momentumAmount; Vector3 a = NGUIMath.SpringDampen(ref vector2, 9f, 2f); Vector3 b = vector - a * 0.01f; float num = float.MaxValue; Transform target = null; int index = 0; int num2 = 0; UIGrid component = base.GetComponent <UIGrid>(); List <Transform> list = null; if (component != null) { list = component.GetChildList(); int i = 0; int count = list.Count; int num3 = 0; while (i < count) { Transform transform2 = list[i]; if (transform2.gameObject.activeInHierarchy) { float num4 = Vector3.SqrMagnitude(transform2.position - b); if (num4 < num) { num = num4; target = transform2; index = i; num2 = num3; } num3++; } i++; } } else { int j = 0; int childCount = transform.childCount; int num5 = 0; while (j < childCount) { Transform child = transform.GetChild(j); if (child.gameObject.activeInHierarchy) { float num6 = Vector3.SqrMagnitude(child.position - b); if (num6 < num) { num = num6; target = child; index = j; num2 = num5; } num5++; } j++; } } if (this.nextPageThreshold > 0f && UICamera.currentTouch != null && this.mCenteredObject != null && this.mCenteredObject.transform == ((list != null) ? list[index] : transform.GetChild(index))) { Vector3 vector3 = UICamera.currentTouch.totalDelta; vector3 = base.transform.rotation * vector3; UIScrollView.Movement movement = this.mScrollView.movement; float num7; if (movement != UIScrollView.Movement.Horizontal) { if (movement != UIScrollView.Movement.Vertical) { num7 = vector3.magnitude; } else { num7 = -vector3.y; } } else { num7 = vector3.x; } if (Mathf.Abs(num7) > this.nextPageThreshold) { if (num7 > this.nextPageThreshold) { if (list != null) { if (num2 > 0) { target = list[num2 - 1]; } else { target = ((base.GetComponent <UIWrapContent>() == null) ? list[0] : list[list.Count - 1]); } } else if (num2 > 0) { target = transform.GetChild(num2 - 1); } else { target = ((base.GetComponent <UIWrapContent>() == null) ? transform.GetChild(0) : transform.GetChild(transform.childCount - 1)); } } else if (num7 < -this.nextPageThreshold) { if (list != null) { if (num2 < list.Count - 1) { target = list[num2 + 1]; } else { target = ((base.GetComponent <UIWrapContent>() == null) ? list[list.Count - 1] : list[0]); } } else if (num2 < transform.childCount - 1) { target = transform.GetChild(num2 + 1); } else { target = ((base.GetComponent <UIWrapContent>() == null) ? transform.GetChild(transform.childCount - 1) : transform.GetChild(0)); } } } } this.CenterOn(target, vector); }
static public void CreateScrollView <T>(this UIGrid grid, GameObject templateItem, IList datas, GridItemList <T> scrollItemList, UIBase parentUI) where T : GridBaseItem { if (scrollItemList == null) { scrollItemList = new GridItemList <T>(null, parentUI); } if (scrollItemList.RefreshGrid()) { return; } if (scrollItemList.items == null) { scrollItemList.items = new List <List <T> >(); } List <List <T> > scrollItems = scrollItemList.items; scrollItems.Clear(); // 删除UI项目 grid.transform.DestroyChildren(); UIScrollView scrollView = NGUITools.FindInParents <UIScrollView>(grid.gameObject); if (scrollItems == null) { scrollItems = new List <List <T> >(); } else { scrollItems.Clear(); } int maxPerLine = grid.maxPerLine == 0 ? 1 : grid.maxPerLine; int itemCount; //grid的行(列)数量 int realItemCount; //原本grid的行(列)数量 itemCount = Mathf.CeilToInt((float)datas.Count / (float)maxPerLine); realItemCount = itemCount; int fillCount = 0; //当前scrollView被填满的格子数 int cacheNum = 3; //多出来的缓存格子 Vector3 lastPos = Vector3.zero; UIPanel panel = scrollView.GetComponent <UIPanel>(); panel.onClipMove = null; UIScrollView.Movement moveType = scrollView.movement; if (moveType == UIScrollView.Movement.Vertical) { fillCount = (int)(panel.height / grid.cellHeight); } else if (moveType == UIScrollView.Movement.Horizontal) { fillCount = (int)(panel.width / grid.cellWidth); } scrollView.onMomentumMove = null; // 面板没被占满拖拽回滚 if (!scrollView.disableDragIfFits) { if (itemCount <= fillCount) { lastPos = panel.transform.localPosition; scrollView.onMomentumMove = () => { SpringPanel.Begin(panel.gameObject, lastPos, 13f).strength = 8f; }; } } // 如果item数量大于填满显示面板的数量做优化 if (itemCount >= fillCount + cacheNum) { itemCount = fillCount + cacheNum; int lastIndex = 0; //上次显示出来的第一个格子,在grid数据中的index int maxIndex = itemCount - 1; int minIndex = 0; int forwardCacheNum = 0; //用于缓存向指定方向滑动,预加载的格子数 // 拖拽刷新面板 panel.onClipMove = (uiPanel) => { Vector3 delata = lastPos - panel.transform.localPosition; float distance = -1; int index; //当前显示出来的第一个格子,在grid数据中的index distance = delata.y != 0 ? delata.y : delata.x; // 满的时候向上滑不管它 if (distance > 0 && moveType == UIScrollView.Movement.Vertical) { return; } if (distance < 0 && moveType == UIScrollView.Movement.Horizontal) { return; } distance = Mathf.Abs(distance); if (moveType == UIScrollView.Movement.Horizontal) { index = Mathf.FloorToInt(distance / grid.cellWidth); } else { index = Mathf.FloorToInt(distance / grid.cellHeight); } // 拖拽不满一个单元格 if (index == lastIndex) { return; } realItemCount = Mathf.CeilToInt((float)datas.Count / (float)maxPerLine); // 拉到底了 if (index + itemCount > realItemCount) { if (lastIndex + itemCount == realItemCount) { return; } else { index = realItemCount - itemCount; } } // 重刷 int offset = Math.Abs(index - lastIndex); // 判断要把最上(左)的item移动到最下(右),还是相反 if (lastIndex < index) { //如果有上一次的缓存数量,就清掉 if (forwardCacheNum > 0) { while (forwardCacheNum > 1) { //上(左)移动到下(右) MoveGridItem <T>(scrollItems, moveType, datas, maxPerLine, ref minIndex, ref maxIndex, ref forwardCacheNum, true, true); } } // 滑到底的时候,把上部缓存的那一个item移动到下部 if ((forwardCacheNum > 0 && index + itemCount == realItemCount)) { //上(左)移动到下(右) MoveGridItem <T>(scrollItems, moveType, datas, maxPerLine, ref minIndex, ref maxIndex, ref forwardCacheNum, true, true); } for (int i = 1; i <= offset; i++) { //上(左)移动到下(右) MoveGridItem <T>(scrollItems, moveType, datas, maxPerLine, ref minIndex, ref maxIndex, ref forwardCacheNum, true, false); } } else { forwardCacheNum = forwardCacheNum - offset; //缓存数量 while ((forwardCacheNum < cacheNum - 1 && index >= cacheNum - 1) || (forwardCacheNum < 0 && index < cacheNum - 1)) { // 下(右)移动到上(左) MoveGridItem <T>(scrollItems, moveType, datas, maxPerLine, ref minIndex, ref maxIndex, ref forwardCacheNum, false, true); } } lastIndex = index; }; //如果这个函数BUG了,请把下面解开下面代码的封印,强行不BUG //scrollView.onMomentumMove = () => { }; //scrollView.onMomentumMove = () => { // for (int i = lastIndex; i < itemCount + lastIndex; i++) { // for (int j = 0; j < scrollItems[i - lastIndex].Count; j++) { // scrollItems[i - lastIndex][j].FillItem(datas, i * maxPerLine + j); // } // } //}; } // 添加能填满UI数量的button for (int i = 0; i < itemCount; i++) { for (int j = 0; j < maxPerLine; j++) { if (i * maxPerLine + j >= datas.Count) { break; } GameObject go = NGUITools.AddChild(grid.gameObject, templateItem); go.SetActive(true); T item = go.AddComponent <T>(); item.grid = grid; item.itemCount = itemCount; item.parentUI = parentUI; if (scrollItems.Count - 1 < i) { scrollItems.Add(new List <T>()); } scrollItems[i].Add(item); item.FindItem(); item.FillItem(datas, i * maxPerLine + j); } } scrollItemList.itemCount = (fillCount + cacheNum) * maxPerLine; scrollItemList.grid = grid; scrollItemList.itemTemplate = templateItem; scrollItemList.datas = datas; scrollItemList.panel = panel; lastPos = panel.transform.localPosition; grid.Reposition(); }
private void CreateBind() { var collectionChanged = Source as INotifyCollectionChanged; if (collectionChanged == null) { return; } if (mGrid == null) { mGrid = GetComponent <UIGrid>(); //mGrid.hideInactive = true; } if (mGrid == null) { return; } Reset(); var mList = Source as IList; collectionChanged.CollectionChanged += CollectionChanged; var nSourCount = mList.Count; var nCellCount = transform.childCount; var maxCount = nSourCount > nCellCount ? nSourCount : nCellCount; //List<Transform> cellList = new List<Transform>(); for (var i = 0; i < maxCount; i++) { if (i < nSourCount && i < nCellCount) { GameObject obj = null; for (var j = 0; j < nCellCount; j++) { var o = transform.GetChild(j).gameObject; var b = o.GetComponent <BindDataRoot>(); if (b != null) { if (b.IsBind == false) { obj = o; break; } } } if (mGrid.enabled == false) { mGrid.enabled = true; } mGrid.AddChild(obj.transform); obj.SetActive(true); var binding = obj.GetComponent <BindDataRoot>(); if (binding != null) { binding.SetBindDataSource(mList[i]); } var itemLogic = obj.GetComponent <ListItemLogic>(); if (itemLogic != null) { itemLogic.Index = i; itemLogic.Item = mList[i]; } } else if (i < nSourCount && i >= nCellCount) { AddNewItem(i); } else if (i >= nSourCount && i < nCellCount) { } } }
void AssignObject() { questGrid = Master.GetChildByName(gameObject, "ListQuests").GetComponent <UIGrid> (); pf_questItem = Master.GetGameObjectInPrefabs("UI/QuestItem"); }
void OnDestroy() { UIGrid cardList = transform.parent.GetComponent <UIGrid> (); cardList.Reposition(); }
/// <summary> /// Draw the on-screen selection, knobs, and handle all interaction logic. /// </summary> public void OnSceneGUI() { if (Selection.objects.Length > 1) { return; } NGUIEditorTools.HideMoveTool(true); if (!UIWidget.showHandles) { return; } mWidget = target as UIWidget; Transform t = mWidget.cachedTransform; Event e = Event.current; int id = GUIUtility.GetControlID(s_Hash, FocusType.Passive); EventType type = e.GetTypeForControl(id); Action actionUnderMouse = mAction; Vector3[] handles = GetHandles(mWidget.worldCorners); NGUIHandles.DrawShadowedLine(handles, handles[0], handles[1], handlesColor); NGUIHandles.DrawShadowedLine(handles, handles[1], handles[2], handlesColor); NGUIHandles.DrawShadowedLine(handles, handles[2], handles[3], handlesColor); NGUIHandles.DrawShadowedLine(handles, handles[0], handles[3], handlesColor); // If the widget is anchored, draw the anchors if (mWidget.isAnchored) { DrawAnchorHandle(mWidget.leftAnchor, mWidget.cachedTransform, handles, 0, id); DrawAnchorHandle(mWidget.topAnchor, mWidget.cachedTransform, handles, 1, id); DrawAnchorHandle(mWidget.rightAnchor, mWidget.cachedTransform, handles, 2, id); DrawAnchorHandle(mWidget.bottomAnchor, mWidget.cachedTransform, handles, 3, id); } if (type == EventType.Repaint) { bool showDetails = (mAction == UIWidgetInspector.Action.Scale) || NGUISettings.drawGuides; if (mAction == UIWidgetInspector.Action.None && e.modifiers == EventModifiers.Control) { showDetails = true; } if (NGUITools.GetActive(mWidget) && mWidget.parent == null) { showDetails = true; } if (showDetails) { NGUIHandles.DrawSize(handles, mWidget.width, mWidget.height); } } // Presence of the legacy stretch component prevents resizing bool canResize = (mWidget.GetComponent <UIStretch>() == null); bool[] resizable = new bool[8]; resizable[4] = canResize; // left resizable[5] = canResize; // top resizable[6] = canResize; // right resizable[7] = canResize; // bottom UILabel lbl = mWidget as UILabel; if (lbl != null) { if (lbl.overflowMethod == UILabel.Overflow.ResizeFreely) { resizable[4] = false; // left resizable[5] = false; // top resizable[6] = false; // right resizable[7] = false; // bottom } else if (lbl.overflowMethod == UILabel.Overflow.ResizeHeight) { resizable[5] = false; // top resizable[7] = false; // bottom } } if (mWidget.keepAspectRatio == UIWidget.AspectRatioSource.BasedOnHeight) { resizable[4] = false; resizable[6] = false; } else if (mWidget.keepAspectRatio == UIWidget.AspectRatioSource.BasedOnWidth) { resizable[5] = false; resizable[7] = false; } resizable[0] = resizable[7] && resizable[4]; // bottom-left resizable[1] = resizable[5] && resizable[4]; // top-left resizable[2] = resizable[5] && resizable[6]; // top-right resizable[3] = resizable[7] && resizable[6]; // bottom-right UIWidget.Pivot pivotUnderMouse = GetPivotUnderMouse(handles, e, resizable, true, ref actionUnderMouse); switch (type) { case EventType.Repaint: { Vector3 v0 = HandleUtility.WorldToGUIPoint(handles[0]); Vector3 v2 = HandleUtility.WorldToGUIPoint(handles[2]); if ((v2 - v0).magnitude > 60f) { Vector3 v1 = HandleUtility.WorldToGUIPoint(handles[1]); Vector3 v3 = HandleUtility.WorldToGUIPoint(handles[3]); Handles.BeginGUI(); { for (int i = 0; i < 4; ++i) { DrawKnob(handles[i], mWidget.pivot == pivotPoints[i], resizable[i], id); } if ((v1 - v0).magnitude > 80f) { if (mWidget.leftAnchor.target == null || mWidget.leftAnchor.absolute != 0) { DrawKnob(handles[4], mWidget.pivot == pivotPoints[4], resizable[4], id); } if (mWidget.rightAnchor.target == null || mWidget.rightAnchor.absolute != 0) { DrawKnob(handles[6], mWidget.pivot == pivotPoints[6], resizable[6], id); } } if ((v3 - v0).magnitude > 80f) { if (mWidget.topAnchor.target == null || mWidget.topAnchor.absolute != 0) { DrawKnob(handles[5], mWidget.pivot == pivotPoints[5], resizable[5], id); } if (mWidget.bottomAnchor.target == null || mWidget.bottomAnchor.absolute != 0) { DrawKnob(handles[7], mWidget.pivot == pivotPoints[7], resizable[7], id); } } } Handles.EndGUI(); } } break; case EventType.MouseDown: { if (actionUnderMouse != Action.None) { mStartMouse = e.mousePosition; mAllowSelection = true; if (e.button == 1) { if (e.modifiers == 0) { GUIUtility.hotControl = GUIUtility.keyboardControl = id; e.Use(); } } else if (e.button == 0 && actionUnderMouse != Action.None && Raycast(handles, out mStartDrag)) { mWorldPos = t.position; mLocalPos = t.localPosition; mStartRot = t.localRotation.eulerAngles; mStartDir = mStartDrag - t.position; mStartWidth = mWidget.width; mStartHeight = mWidget.height; mStartLeft.x = mWidget.leftAnchor.relative; mStartLeft.y = mWidget.leftAnchor.absolute; mStartRight.x = mWidget.rightAnchor.relative; mStartRight.y = mWidget.rightAnchor.absolute; mStartBottom.x = mWidget.bottomAnchor.relative; mStartBottom.y = mWidget.bottomAnchor.absolute; mStartTop.x = mWidget.topAnchor.relative; mStartTop.y = mWidget.topAnchor.absolute; mDragPivot = pivotUnderMouse; mActionUnderMouse = actionUnderMouse; GUIUtility.hotControl = GUIUtility.keyboardControl = id; e.Use(); } } } break; case EventType.MouseDrag: { // Prevent selection once the drag operation begins bool dragStarted = (e.mousePosition - mStartMouse).magnitude > 3f; if (dragStarted) { mAllowSelection = false; } if (GUIUtility.hotControl == id) { e.Use(); if (mAction != Action.None || mActionUnderMouse != Action.None) { Vector3 pos; if (Raycast(handles, out pos)) { if (mAction == Action.None && mActionUnderMouse != Action.None) { // Wait until the mouse moves by more than a few pixels if (dragStarted) { if (mActionUnderMouse == Action.Move) { NGUISnap.Recalculate(mWidget); } else if (mActionUnderMouse == Action.Rotate) { mStartRot = t.localRotation.eulerAngles; mStartDir = mStartDrag - t.position; } else if (mActionUnderMouse == Action.Scale) { mStartWidth = mWidget.width; mStartHeight = mWidget.height; mDragPivot = pivotUnderMouse; } mAction = actionUnderMouse; } } if (mAction != Action.None) { NGUIEditorTools.RegisterUndo("Change Rect", t); NGUIEditorTools.RegisterUndo("Change Rect", mWidget); // Reset the widget before adjusting anything t.position = mWorldPos; mWidget.width = mStartWidth; mWidget.height = mStartHeight; mWidget.leftAnchor.Set(mStartLeft.x, mStartLeft.y); mWidget.rightAnchor.Set(mStartRight.x, mStartRight.y); mWidget.bottomAnchor.Set(mStartBottom.x, mStartBottom.y); mWidget.topAnchor.Set(mStartTop.x, mStartTop.y); if (mAction == Action.Move) { // Move the widget t.position = mWorldPos + (pos - mStartDrag); Vector3 after = t.localPosition; bool snapped = false; Transform parent = t.parent; if (parent != null) { UIGrid grid = parent.GetComponent <UIGrid>(); if (grid != null && grid.arrangement == UIGrid.Arrangement.CellSnap) { snapped = true; if (grid.cellWidth > 0) { after.x = Mathf.Round(after.x / grid.cellWidth) * grid.cellWidth; } if (grid.cellHeight > 0) { after.y = Mathf.Round(after.y / grid.cellHeight) * grid.cellHeight; } } } if (!snapped) { // Snap the widget after = NGUISnap.Snap(after, mWidget.localCorners, e.modifiers != EventModifiers.Control); } // Calculate the final delta Vector3 localDelta = (after - mLocalPos); // Restore the position t.position = mWorldPos; // Adjust the widget by the delta NGUIMath.MoveRect(mWidget, localDelta.x, localDelta.y); } else if (mAction == Action.Rotate) { Vector3 dir = pos - t.position; float angle = Vector3.Angle(mStartDir, dir); if (angle > 0f) { float dot = Vector3.Dot(Vector3.Cross(mStartDir, dir), t.forward); if (dot < 0f) { angle = -angle; } angle = mStartRot.z + angle; angle = (NGUISnap.allow && e.modifiers != EventModifiers.Control) ? Mathf.Round(angle / 15f) * 15f : Mathf.Round(angle); t.localRotation = Quaternion.Euler(mStartRot.x, mStartRot.y, angle); } } else if (mAction == Action.Scale) { // Move the widget t.position = mWorldPos + (pos - mStartDrag); // Calculate the final delta Vector3 localDelta = (t.localPosition - mLocalPos); // Restore the position t.position = mWorldPos; // Adjust the widget's position and scale based on the delta, restricted by the pivot NGUIMath.ResizeWidget(mWidget, mDragPivot, localDelta.x, localDelta.y, 2, 2); ReEvaluateAnchorType(); } } } } } } break; case EventType.MouseUp: { if (e.button == 2) { break; } if (GUIUtility.hotControl == id) { GUIUtility.hotControl = 0; GUIUtility.keyboardControl = 0; if (e.button < 2) { bool handled = false; if (e.button == 1) { // Right-click: Open a context menu listing all widgets underneath NGUIEditorTools.ShowSpriteSelectionMenu(e.mousePosition); handled = true; } else if (mAction == Action.None) { if (mAllowSelection) { // Left-click: Select the topmost widget NGUIEditorTools.SelectWidget(e.mousePosition); handled = true; } } else { // Finished dragging something Vector3 pos = t.localPosition; pos.x = Mathf.Round(pos.x); pos.y = Mathf.Round(pos.y); pos.z = Mathf.Round(pos.z); t.localPosition = pos; handled = true; } if (handled) { e.Use(); } } // Clear the actions mActionUnderMouse = Action.None; mAction = Action.None; } else if (mAllowSelection) { List <UIWidget> widgets = NGUIEditorTools.SceneViewRaycast(e.mousePosition); if (widgets.Count > 0) { Selection.activeGameObject = widgets[0].gameObject; } } mAllowSelection = true; } break; case EventType.KeyDown: { if (e.keyCode == KeyCode.UpArrow) { NGUIEditorTools.RegisterUndo("Nudge Rect", t); NGUIEditorTools.RegisterUndo("Nudge Rect", mWidget); NGUIMath.MoveRect(mWidget, 0f, 1f); e.Use(); } else if (e.keyCode == KeyCode.DownArrow) { NGUIEditorTools.RegisterUndo("Nudge Rect", t); NGUIEditorTools.RegisterUndo("Nudge Rect", mWidget); NGUIMath.MoveRect(mWidget, 0f, -1f); e.Use(); } else if (e.keyCode == KeyCode.LeftArrow) { NGUIEditorTools.RegisterUndo("Nudge Rect", t); NGUIEditorTools.RegisterUndo("Nudge Rect", mWidget); NGUIMath.MoveRect(mWidget, -1f, 0f); e.Use(); } else if (e.keyCode == KeyCode.RightArrow) { NGUIEditorTools.RegisterUndo("Nudge Rect", t); NGUIEditorTools.RegisterUndo("Nudge Rect", mWidget); NGUIMath.MoveRect(mWidget, 1f, 0f); e.Use(); } else if (e.keyCode == KeyCode.Escape) { if (GUIUtility.hotControl == id) { if (mAction != Action.None) { Undo.PerformUndo(); } GUIUtility.hotControl = 0; GUIUtility.keyboardControl = 0; mActionUnderMouse = Action.None; mAction = Action.None; e.Use(); } else { Selection.activeGameObject = null; } } } break; } }
/// <summary> /// Drop the item onto the specified object. /// </summary> protected virtual void OnDragDropRelease(GameObject surface) { if (!cloneOnDrag) { mTouchID = int.MinValue; // Re-enable the collider if (mButton != null) { mButton.isEnabled = true; } else if (mCollider != null) { mCollider.enabled = true; } // Is there a droppable container? UIDragDropContainer container = surface ? NGUITools.FindInParents <UIDragDropContainer>(surface) : null; if (container != null) { // Container found -- parent this object to the container mTrans.parent = (container.reparentTarget != null) ? container.reparentTarget : container.transform; Vector3 pos = mTrans.localPosition; pos.z = 0f; mTrans.localPosition = pos; } else { // No valid container under the mouse -- revert the item's parent mTrans.parent = mParent; } // Update the grid and table references mParent = mTrans.parent; mGrid = NGUITools.FindInParents <UIGrid>(mParent); mTable = NGUITools.FindInParents <UITable>(mParent); // Re-enable the drag scroll view script if (mDragScrollView != null) { mDragScrollView.enabled = true; } // Notify the widgets that the parent has changed NGUITools.MarkParentAsChanged(gameObject); if (mTable != null) { mTable.repositionNow = true; } if (mGrid != null) { mGrid.repositionNow = true; } } else { NGUITools.Destroy(gameObject); } }
// Start is called before the first frame update void Start() { grid = new UIGrid(4, 2, 10f, new Vector3(20, 0)); }
public void OnCancel(UIGrid grid) { // Never mind. Just deactivate the share hub and reactivate main menu. ActivateMainMenu(); } // end of OnCancel()
static JsonData GetNodeJson(GameObject go) { JsonData node = new JsonData(); node["name"] = go.name; node["pos"] = new JsonData(); // 保留小数点后两位 node["pos"]["x"] = System.Math.Round((double)go.transform.localPosition.x, 2); node["pos"]["y"] = System.Math.Round((double)go.transform.localPosition.y, 2); node["scale"] = new JsonData(); node["scale"]["x"] = System.Math.Round((double)go.transform.localScale.x, 2); node["scale"]["y"] = System.Math.Round((double)go.transform.localScale.y, 2); node["rotation"] = System.Math.Round((double)go.transform.localEulerAngles.z, 2); node["active"] = go.activeSelf; Component[] comps = go.GetComponents <UIWidget>(); if (comps.Length > 0) { node["components"] = new JsonData(); foreach (UIWidget comp in comps) { JsonData cj = new JsonData(); cj["type"] = comp.GetType().ToString(); cj["size"] = new JsonData(); cj["size"]["width"] = comp.width; cj["size"]["height"] = comp.height; cj["color"] = ColorUtility.ToHtmlStringRGB(comp.color); cj["depth"] = comp.depth; cj["pivot"] = comp.pivot.ToString(); if (comp is UILabel) { UILabel label = (comp as UILabel); cj["text"] = label.text; cj["fontSize"] = label.fontSize; cj["overflow"] = label.overflowMethod.ToString(); if (label.effectStyle == UILabel.Effect.Outline || label.effectStyle == UILabel.Effect.Outline8) { cj["outlineColor"] = ColorUtility.ToHtmlStringRGB(label.effectColor); cj["outlineWidth"] = label.effectiveSpacingX; } cj["spacingX"] = label.spacingX; cj["spacingY"] = label.spacingY; if (label.bitmapFont) { // Debug.Log(label.bitmapFont.name); cj["bitmapFont"] = label.bitmapFont.name; } } if (comp is UISprite) { UISprite sprite = comp as UISprite; cj["spType"] = sprite.type.ToString(); cj["spName"] = sprite.spriteName; if (sprite.atlas) { cj["atlas"] = sprite.atlas.name; } if (sprite.border != Vector4.zero) { cj["border"] = new JsonData(); cj["border"]["left"] = sprite.border.x; cj["border"]["right"] = sprite.border.z; cj["border"]["top"] = sprite.border.w; cj["border"]["bottom"] = sprite.border.y; // Debug.Log("border: " + sprite.spriteName + " node: " + go.name); } if (sprite.type == UIBasicSprite.Type.Filled) { cj["fillDir"] = (uint)sprite.fillDirection; } } if (comp is UITexture) { UITexture texture = comp as UITexture; if (texture.mainTexture != null) { cj["spName"] = texture.mainTexture.name; cj["spType"] = texture.type.ToString(); } } node["components"].Add(cj); } } Component[] boxes = go.GetComponents <BoxCollider>(); if (boxes.Length > 0) { node["button"] = true; } UIScrollView sv = go.GetComponent <UIScrollView>(); if (sv) { UIPanel panel = go.GetComponent <UIPanel>(); node["scrollView"] = new JsonData(); node["scrollView"]["offset"] = new JsonData(); node["scrollView"]["offset"]["x"] = panel.clipOffset.x + panel.finalClipRegion.x; node["scrollView"]["offset"]["y"] = panel.clipOffset.y + panel.finalClipRegion.y; node["scrollView"]["size"] = new JsonData(); node["scrollView"]["size"]["x"] = panel.finalClipRegion.z; node["scrollView"]["size"]["y"] = panel.finalClipRegion.w; node["scrollView"]["movement"] = (int)sv.movement; } UIGrid grid = go.GetComponent <UIGrid>(); if (grid && grid.enabled) { node["grid"] = new JsonData(); node["grid"]["arrangement"] = (uint)grid.arrangement; } if (go.transform.childCount > 0) { node["children"] = new JsonData(); for (int i = 0, len = go.transform.childCount; i < len; ++i) { JsonData child = GetNodeJson(go.transform.GetChild(i).gameObject); node["children"].Add(child); } } return(node); }
void InitThreeServer() { List <ServerInfo> serverList = FCDownloadManager.Instance.GameServers; serverList.Sort(ServerInfo.CompareServerFromMaxToMin); //paixu const int Count = 3; List <ServerInfo> threeServerList = new List <ServerInfo>(); ServerInfo serverInfo = GetServerInfoFromCache(PrefsKey.ServerCacheOne); if (null != serverInfo) { threeServerList.Add(serverInfo); } serverInfo = GetServerInfoFromCache(PrefsKey.ServerCacheTwo); if (null != serverInfo) { threeServerList.Add(serverInfo); } if (threeServerList.Count >= 1) { foreach (ServerInfo info in serverList) { if (threeServerList.Count >= Count) { break; } if (!threeServerList.Contains(info)) { threeServerList.Add(info); } } } else { List <ServerInfo> recommendedList = serverList.FindAll( delegate(ServerInfo info) { return(info.state == ServerState.Recommended); }); foreach (ServerInfo info in recommendedList) { if (threeServerList.Count >= Count) { break; } if (!threeServerList.Contains(info)) { threeServerList.Add(info); } } if (threeServerList.Count < Count) { foreach (ServerInfo info in serverList) { if (threeServerList.Count >= Count) { break; } if (!threeServerList.Contains(info)) { threeServerList.Add(info); } } } } int index = 0; foreach (ServerInfo info in threeServerList) { ServerButtonImage buttonImage = GetServerButtonImageByState(info.state); GameObject obj = NGUITools.AddChild(cacheGrid.gameObject, cloneSingle.gameObject); UISingleServer singServer = obj.GetComponent <UISingleServer>(); singServer.Init(this, info, buttonImage, true); singServer.gameObject.SetActive(true); singServer.name = string.Format("sort{0}", index.ToString("000")); ++index; } UIGrid uigrid = cacheGrid.GetComponent <UIGrid>(); uigrid.repositionNow = true; }
void Awake() { // Forces a different code path in the BinaryFormatter that doesn't rely on run-time code generation (which would break on iOS). Environment.SetEnvironmentVariable("MONO_REFLECTION_SERIALIZER", "yes"); grid = gridObject.GetComponent <UIGrid>(); }
//-------------------------------------------------------- // 内部调用 //-------------------------------------------------------- void InsertOneItem(UIGrid grid, GameObject itemGameObject, uint rmb, uint diamond, string iconName, PkgDepositAct payActivity) { Transform rootTrans = itemGameObject.transform.parent; GameObject item = UIMain.InstUIObject(itemGameObject); Transform itemTrans = item.transform; itemTrans.localScale = Vector3.one; // 图标 UISprite iconSprite = itemTrans.FindChild("IconSprite").GetComponent <UISprite>(); iconSprite.spriteName = iconName; iconSprite.MakePixelPerfect(); // 钻石 itemTrans.FindChild("DiamondLabel").GetComponent <UILabel>().text = "[b]" + diamond.ToString() /* + DBConstText.GetText("MONEY_DIAMOND_NAME")*/; // 人民币 itemTrans.FindChild("RMBLabel").GetComponent <UILabel>().text = "[b]" + rmb.ToString(); // 充值活动 GameObject activityGameObject = itemTrans.FindChild("ActivityBgSprite").gameObject; GameObject firstDoubleGameObject = activityGameObject.transform.FindChild("FirstDoubleSprite").gameObject; firstDoubleGameObject.SetActive(false); GameObject giveExtraGameObject = activityGameObject.transform.FindChild("GiveExtraSprite").gameObject; giveExtraGameObject.SetActive(false); bool hasActivity = false; if (payActivity != null) { if (payActivity.type == (uint)PayManager.EPayActivity.None) { } else if (payActivity.type == (uint)PayManager.EPayActivity.FirstDouble) { hasActivity = true; firstDoubleGameObject.SetActive(true); } else if (payActivity.type == (uint)PayManager.EPayActivity.GetFirstDouble) { } else if (payActivity.type == (uint)PayManager.EPayActivity.GiveExtra) { hasActivity = true; giveExtraGameObject.SetActive(true); UILabel giveExtraLabel = giveExtraGameObject.transform.FindChild("GiveExtraLabel").GetComponent <UILabel>(); giveExtraLabel.text = "[b]" + payActivity.rate.ToString(); } } if (hasActivity == false) { activityGameObject.SetActive(false); } else { activityGameObject.SetActive(true); } UIButton button = itemTrans.GetComponent <UIButton>(); button.Param = rmb; EventDelegate.Add(button.onClick, OnClickPayButton); item.name = rmb.ToString(); item.SetActive(true); grid.AddChild(item.transform); }
public override void Awake() { base.Awake(); var t = controller.transform; uIGrid = t.Find("Edge/Bottom/Grid").GetComponent <UIGrid>(); SelectSwitchEquip = t.Find("Edge/Bottom/Grid/SwitchEquipBtn/SelectToggle").GetComponent <UIToggle>(); SelectSwitchPeak = t.Find("Edge/Bottom/Grid/SwitchPeakBtn/SelectToggle").GetComponent <UIToggle>(); SelectSwitchPo = t.Find("Edge/Bottom/Grid/SwitchPoBtn/SelectToggle").GetComponent <UIToggle>(); typeSprite_1 = t.GetComponent <UISprite>("Edge/Center/LeftPartCell/Type"); typeSprite_2 = t.GetComponent <UISprite>("Edge/Center/RightPartCell/Type"); leftNameLabel = t.GetComponent <UILabel>("Edge/Center/LeftPartCell/Label"); rightNameLabel = t.GetComponent <UILabel>("Edge/Center/RightPartCell/Label (1)"); transPriceLabel = t.GetComponent <UILabel>("Edge/Bottom/TransBtn/Label_1"); DiamondSprite = t.GetComponent <UISprite>("Edge/Bottom/TransBtn/Sprite"); pricefreelabel = t.FindEx("Edge/Bottom/TransBtn/Label_2").gameObject; DynamicScroll = t.GetMonoILRComponent <CombatPartnerDynamicScroll>("Edge/Bottom/BuddyList/Placeholder/PartnerGrid"); DragPartnerCell = t.GetMonoILRComponent <CombatPartnerCellController>("Edge/DragPanel/DragPartnerItem"); LeftFx = t.FindEx("Edge/Center/LeftPartCell/Container/fx_hb_UI_Zhuanhuan_1").gameObject; RightFx = t.FindEx("Edge/Center/RightPartCell/Container/fx_hb_UI_Zhuanhuan_2").gameObject; DRAG_Z = -2f; MIN_DRAG_DIST = 0.35f; DRAG_OFFSET_DIST = 0.12f; MIN_DRAG_IN_DIST = 0.34f; CHALLENGE_MIN_DRAG_IN_DIST = 0.2f; judgePosLeft = t.GetComponent <Transform>("Edge/Center/LeftPartCell/Container"); judgePosRight = t.GetComponent <Transform>("Edge/Center/RightPartCell/Container"); leftIcon = t.GetMonoILRComponent <CombatPartnerCellController>("Edge/Center/LeftPartCell/Container/DragPartnerItem"); rightIcon = t.GetMonoILRComponent <CombatPartnerCellController>("Edge/Center/RightPartCell/Container/DragPartnerItem"); MoveSpeed = 5f; tempWorldVec = Vector3.zero; UIButton backButton = t.GetComponent <UIButton>("Edge/LeftUp/CancelBtn"); backButton.onClick.Add(new EventDelegate(OnCancelButtonClick)); BattleReadyTitle battleReady = t.GetMonoILRComponent <BattleReadyTitle>("Edge/Bottom/BG/Title"); UIButton AllBtn = t.GetComponent <UIButton>("Edge/Bottom/BG/Title/BtnList/AllBtn"); AllBtn.onClick.Add(new EventDelegate(() => OnRaceTabClick(t.FindEx("Edge/Bottom/BG/Title/BtnList/AllBtn").gameObject))); UIButton FengBtn = t.GetComponent <UIButton>("Edge/Bottom/BG/Title/BtnList/FengBtn"); FengBtn.onClick.Add(new EventDelegate(() => OnRaceTabClick(t.FindEx("Edge/Bottom/BG/Title/BtnList/FengBtn").gameObject))); UIButton HuoBtn = t.GetComponent <UIButton>("Edge/Bottom/BG/Title/BtnList/HuoBtn"); HuoBtn.onClick.Add(new EventDelegate(() => OnRaceTabClick(t.FindEx("Edge/Bottom/BG/Title/BtnList/HuoBtn").gameObject))); UIButton ShuiBtn = t.GetComponent <UIButton>("Edge/Bottom/BG/Title/BtnList/ShuiBtn"); ShuiBtn.onClick.Add(new EventDelegate(() => OnRaceTabClick(t.FindEx("Edge/Bottom/BG/Title/BtnList/ShuiBtn").gameObject))); AllBtn.onClick.Add(new EventDelegate(() => { battleReady.OnTitleBtnClick(AllBtn.transform.FindEx("Sprite").gameObject); })); FengBtn.onClick.Add(new EventDelegate(() => { battleReady.OnTitleBtnClick(FengBtn.transform.FindEx("Sprite").gameObject); })); HuoBtn.onClick.Add(new EventDelegate(() => { battleReady.OnTitleBtnClick(HuoBtn.transform.FindEx("Sprite").gameObject); })); ShuiBtn.onClick.Add(new EventDelegate(() => { battleReady.OnTitleBtnClick(ShuiBtn.transform.FindEx("Sprite").gameObject); })); t.GetComponent <ConsecutiveClickCoolTrigger>("Edge/Bottom/TransBtn").clickEvent.Add(new EventDelegate(OnPartnerTransClick)); t.GetComponent <UIButton>("Edge/Bottom/RuleBtn").onClick.Add(new EventDelegate(OnRuleBtnClick)); t.GetComponent <ContinueClickCDTrigger>("Edge/Center/LeftPartCell/Container").m_CallBackPress.Add(new EventDelegate(() => OnClickOutTeam(t.GetComponent <Transform>("Edge/Center/LeftPartCell/Container"), t.GetComponent <UILabel>("Edge/Center/LeftPartCell/Label")))); t.GetComponent <ContinueClickCDTrigger>("Edge/Center/RightPartCell/Container").m_CallBackPress.Add(new EventDelegate(() => OnClickOutTeam(t.GetComponent <Transform>("Edge/Center/RightPartCell/Container"), t.GetComponent <UILabel>("Edge/Center/RightPartCell/Label (1)")))); }
public override void OnLoadedUI(bool close3dTouch, object args) { base.OnLoadedUI(close3dTouch, args); _btnEmoji = transform.Find("L/botton1").gameObject; _btnItem = transform.Find("L/botton2").gameObject; _btnPet = transform.Find("L/botton3").gameObject; _btnTask = transform.Find("L/botton4").gameObject; _btnHonor = transform.Find("L/botton5").gameObject; _btnQuickTalk = transform.Find("L/botton6").gameObject; _btnHistory = transform.Find("L/botton7").gameObject; _emojiPanel = transform.Find("R/Emoji"); _gridEmoji = transform.Find("R/Emoji/Grid").GetComponent <UIGrid>(); _emojiTemplate = transform.Find("R/Emoji/emoji_template").gameObject; _emojiTemplate.SetActive(false); _emojiGridList = new GridItemList <EmojiListItem>(null, this); _bagPanel = transform.Find("R/Bag"); _btnAllItem = transform.Find("R/Bag/bottom1").gameObject; _btnPotionItem = transform.Find("R/Bag/bottom2").gameObject; _gridBag = transform.Find("R/Bag/Scroll View/Grid").GetComponent <UIGrid>(); _petPanel = transform.Find("R/Pet"); _gridPet = transform.Find("R/Pet/Grid").GetComponent <UIGrid>(); _petTemplate = transform.Find("R/Pet/pet_template").gameObject; _petTemplate.SetActive(false); _taskPanel = transform.Find("R/quest"); _gridTask = transform.Find("R/quest/Grid").GetComponent <UIGrid>(); _taskTemplate = transform.Find("R/quest/quest_template").gameObject; _taskTemplate.SetActive(false); _honorPanel = transform.Find("R/chenghao"); _gridHonor = transform.Find("R/chenghao/Grid").GetComponent <UIGrid>(); _honorTemplate = transform.Find("R/chenghao/honor_template").gameObject; _honorTemplate.SetActive(false); _quickTalkPanel = transform.Find("R/massage"); _gridTalk = transform.Find("R/massage/Grid").GetComponent <UIGrid>(); _talkTemplate = transform.Find("R/massage/message_template").gameObject; _historyPanel = transform.Find("R/History"); _gridHistory = transform.Find("R/History/Grid").GetComponent <UIGrid>(); _historyTemplate = transform.Find("R/History/history_template").gameObject; _historyTemplate.SetActive(false); _historyGridList = new GridItemList <ChatHistoryItem>(null, this); _historyList = ChatDataManager.GetInstance().history; _parentUI = GetParentUI <ChatDetailView>(); List <List <Transform> > contents = new List <List <Transform> > { new List <Transform> { _emojiPanel }, new List <Transform> { _bagPanel }, new List <Transform> { _petPanel }, new List <Transform> { _taskPanel }, new List <Transform> { _honorPanel }, new List <Transform> { _quickTalkPanel }, new List <Transform> { _historyPanel }, }; List <GameObject> activeButtons = new List <GameObject> { _btnEmoji, _btnItem, _btnPet, _btnTask, _btnHonor, _btnQuickTalk, _btnHistory, }; _emojiNames = new List <string>(); _emojiNames.Add("000_2"); _emojiNames.Add("001_2"); _emojiNames.Add("002_2"); _gridEmoji.CreateScrollView <EmojiListItem>(_emojiTemplate, _emojiNames, _emojiGridList, GetParentUI <ChatDetailView>()); UIWidgetTools.RegistUITapButton(activeButtons, contents); RegistUIButton(_btnHistory, (go) => { RefreshHistory(); }); }
/// <summary> /// Perform any logic related to starting the drag & drop operation. /// </summary> protected virtual void OnDragDropStart() { // Automatically disable the scroll view if (mDragScrollView != null) { mDragScrollView.enabled = false; } // Disable the collider so that it doesn't intercept events if (mButton != null) { mButton.isEnabled = false; } else if (mCollider != null) { mCollider.enabled = false; } else if (mCollider2D != null) { mCollider2D.enabled = false; } mTouchID = UICamera.currentTouchID; mParent = mTrans.parent; mRoot = NGUITools.FindInParents <UIRoot>(mParent); mGrid = NGUITools.FindInParents <UIGrid>(mParent); mTable = NGUITools.FindInParents <UITable>(mParent); // Re-parent the item if (UIDragDropRoot.root != null) { mTrans.parent = UIDragDropRoot.root; } Vector3 pos = mTrans.localPosition; pos.z = 0f; mTrans.localPosition = pos; TweenPosition tp = GetComponent <TweenPosition>(); if (tp != null) { tp.enabled = false; } SpringPosition sp = GetComponent <SpringPosition>(); if (sp != null) { sp.enabled = false; } // Notify the widgets that the parent has changed NGUITools.MarkParentAsChanged(gameObject); if (mTable != null) { mTable.repositionNow = true; } if (mGrid != null) { mGrid.repositionNow = true; } }
private void OnRefreshVIPPrivilegeUIInfo(List <KeyValuePair <string, VIPPrivilegeItem> > list) { UIGrid gridParent = controller.UiGrids["PrivilegeGrid"]; List <Transform> itemList = gridParent.GetChildList(); if (itemList != null) { itemList.Sort((left, right) => { if (left.localPosition.y < right.localPosition.y) { return(1); } else { return(-1); } }); } int index = 0; int posindex = 0; for (int i = 0; i < list.Count; i++) { VIPPrivilegeItem itemData = list[i].Value; GameObject itemObject = null; if (itemList != null && index < itemList.Count) { itemObject = itemList[index].gameObject; } else { itemObject = Object.Instantiate(m_PrivilegeItemPrefab); gridParent.AddChild(itemObject.transform); } itemObject.GetComponent <UIWidget>().alpha = 1; UILabel label = itemObject.transform.Find("Content").GetComponent <UILabel>(); UISprite icon = itemObject.transform.Find("Icon").GetComponent <UISprite>(); label.transform.gameObject.CustomSetActive(true); icon.transform.gameObject.CustomSetActive(true); itemObject.transform.localScale = Vector3.one; label.text = LTVIPDataManager.Instance.GetPrivilegeContent(itemData, list[i].Key); icon.color = itemData.Status == PrivilegeStatus.Newly ? Color.yellow : Color.white; posindex = label.height / 40 - 1; if (posindex > 0) { for (int j = 0; j < posindex; j++) { index++; if (itemList != null && index < itemList.Count) { itemObject = itemList[index].gameObject; } else { itemObject = Object.Instantiate(m_PrivilegeItemPrefab); gridParent.AddChild(itemObject.transform); } itemObject.transform.Find("Icon").gameObject.CustomSetActive(false); itemObject.transform.Find("Content").gameObject.CustomSetActive(false); itemObject.transform.localScale = Vector3.one; } } index++; } if (itemList != null && index < itemList.Count) { for (int i = index; i < itemList.Count; i++) { itemList[i].gameObject.GetComponent <UIWidget>().alpha = 0; } } controller.GObjects["PrivilegeArrow"].SetActive(index > 12); gridParent.Reposition(); ResetUIScrollView(gridParent, index); }
/// <summary> /// 显示背包中的高级、顶级技能书 /// </summary> void ShowBookInBag() { int lenth = choosedPetSkill.Count; if (lenth <= 0) { if (noNeedBook != null) { noNeedBook.gameObject.SetActive(true); } } else { noNeedBook.gameObject.SetActive(false); } if (parent != null) { UIGrid grid = parent.GetComponent <UIGrid>(); grid.maxPerLine = lenth / 2 + lenth % 2; } foreach (BookItem book in bookInBag.Values) { book.gameObject.SetActive(false); } ItemUI choodeitem = composeBookBtn.GetComponent <ItemUI>(); for (int i = 0; i < lenth; i++) { int id = choosedPetSkill[i]; if (choodeitem != null && choodeitem.EQInfo != null) { EquipmentRef info = ConfigMng.Instance.GetEquipmentRef(id); if (info.psetSkillLevel < needLev) { continue; } } if (!bookInBag.ContainsKey(id))//创建 { BookItem item = BookItem.CeateNew(i, parent, true); item.gameObject.SetActive(true); item.chooseBtn.gameObject.SetActive(true); item.chooseYetBtn.gameObject.SetActive(false); item.curType = ChooseType.GETMAT; ItemUI bookItem = item.GetComponent <ItemUI>(); bookItem.FillInfo(new EquipmentInfo(id, GameCenter.inventoryMng.GetNumberByType(id), EquipmentBelongTo.PREVIEW)); int num = 0; for (int j = 0; j < choosedBookInMat.Count; j++) { if (id == choosedBookInMat[j]) { ++num; } } bookItem.FillInfo(new EquipmentInfo(id, GameCenter.inventoryMng.GetNumberByType(id) - num, EquipmentBelongTo.PREVIEW)); if (item.chooseBtn != null) { UIEventListener.Get(item.chooseBtn.gameObject).onClick -= OnClickChooseToMat; UIEventListener.Get(item.chooseBtn.gameObject).onClick += OnClickChooseToMat; UIEventListener.Get(item.chooseBtn.gameObject).parameter = id; } bookInBag[id] = item; } else//刷新 { BookItem book = bookInBag[id] as BookItem; book.gameObject.SetActive(true); book.transform.localPosition = new Vector3((i % 2) * 120, -(i / 2) * 168); book.chooseBtn.gameObject.SetActive(true); book.chooseYetBtn.gameObject.SetActive(false); ItemUI bookItem = book.GetComponent <ItemUI>(); bookItem.FillInfo(new EquipmentInfo(id, GameCenter.inventoryMng.GetNumberByType(id), EquipmentBelongTo.PREVIEW)); int num = 0; for (int j = 0; j < choosedBookInMat.Count; j++) { if (id == choosedBookInMat[j]) { ++num; } } bookItem.FillInfo(new EquipmentInfo(id, (GameCenter.inventoryMng.GetNumberByType(id) - num), EquipmentBelongTo.PREVIEW)); } } }
// Use this for initialization void FindGrid() { mGrid = mRoot.gameObject.GetComponentInChildren <UIGrid>(); mView = mRoot.gameObject.GetComponent <UIScrollView>(); }
public void ResetCostPostion() { UIGrid grid = mCostGrid.GetComponent <UIGrid>(); grid.repositionNow = true; }
// Use this for initialization void Awake() { grid = GetComponent <UIGrid>(); }
public void OnSelect(UIGrid grid) { // User selected a friend. grid.Active = true; int index = shared.grid.SelectionIndex.Y; UIGridShareFriendElement friendElement = shared.grid.Get(0, index) as UIGridShareFriendElement; UIGridSharingServerElement serverElement = shared.grid.Get(0, index) as UIGridSharingServerElement; if (friendElement != null) { if (friendElement.Friend.IsOnline) { if (friendElement.Friend.InvitedUs || friendElement.Friend.IsJoinable) { // Friend has a joinable session, directly join it ("jump in"). StartJumpingIn(friendElement.Friend.GamerTag, friendElement); // Don't allow the user to interact with the share hub while the SessionFinder is running. grid.Active = false; } else if (friendElement.Friend.IsJoined && LiveManager.IsConnected) { // Selected friend has joined our session, just go to the sharing room. ActivateSharingScreen(); grid.Active = false; } else if (!friendElement.Friend.InvitedThem) { // Start sending an invitation to this friend. friendElement.Friend.InvitingThem = true; if (!LiveManager.IsConnected) { openingInviteGuideMessage.Activate(); LiveManager.ClearQueuedOperations(null); // We must have a session open before we can send an invite. // Start creating the network session. SessionCreator createOp = new SessionCreator(SessionCreatorComplete_StartInvitingFriend, friendElement, this); createOp.Queue(); } else { // Session is already open, no need to create it before sending the invite. StartInvitingFriend(friendElement); } } } } else if (serverElement != null) { if (serverElement.IsOnline) { StartJumpingIn(serverElement.GamerTag, serverElement); // Don't allow the user to interact with the share hub while the SessionFinder is running. grid.Active = false; } } }
//初始化控件变量 protected override void InitControls() { fastComponent = GetComponent <FastComponent>(); fastComponent.BuildFastComponents(); m__MainPlayerIcon = fastComponent.FastGetComponent <UITexture>("MainPlayerIcon"); if (null == m__MainPlayerIcon) { Engine.Utility.Log.Error("m__MainPlayerIcon 为空,请检查prefab是否缺乏组件"); } m_label_MainPlayerLevel = fastComponent.FastGetComponent <UILabel>("MainPlayerLevel"); if (null == m_label_MainPlayerLevel) { Engine.Utility.Log.Error("m_label_MainPlayerLevel 为空,请检查prefab是否缺乏组件"); } m_label_MainPlayerName = fastComponent.FastGetComponent <UILabel>("MainPlayerName"); if (null == m_label_MainPlayerName) { Engine.Utility.Log.Error("m_label_MainPlayerName 为空,请检查prefab是否缺乏组件"); } m_label_MyRanking = fastComponent.FastGetComponent <UILabel>("MyRanking"); if (null == m_label_MyRanking) { Engine.Utility.Log.Error("m_label_MyRanking 为空,请检查prefab是否缺乏组件"); } m_label_MyFighting = fastComponent.FastGetComponent <UILabel>("MyFighting"); if (null == m_label_MyFighting) { Engine.Utility.Log.Error("m_label_MyFighting 为空,请检查prefab是否缺乏组件"); } m_btn_btn_report = fastComponent.FastGetComponent <UIButton>("btn_report"); if (null == m_btn_btn_report) { Engine.Utility.Log.Error("m_btn_btn_report 为空,请检查prefab是否缺乏组件"); } m_btn_btn_store = fastComponent.FastGetComponent <UIButton>("btn_store"); if (null == m_btn_btn_store) { Engine.Utility.Log.Error("m_btn_btn_store 为空,请检查prefab是否缺乏组件"); } m_btn_btn_ranklist = fastComponent.FastGetComponent <UIButton>("btn_ranklist"); if (null == m_btn_btn_ranklist) { Engine.Utility.Log.Error("m_btn_btn_ranklist 为空,请检查prefab是否缺乏组件"); } m_btn_btn_setskill = fastComponent.FastGetComponent <UIButton>("btn_setskill"); if (null == m_btn_btn_setskill) { Engine.Utility.Log.Error("m_btn_btn_setskill 为空,请检查prefab是否缺乏组件"); } m_label_number_challenge = fastComponent.FastGetComponent <UILabel>("number_challenge"); if (null == m_label_number_challenge) { Engine.Utility.Log.Error("m_label_number_challenge 为空,请检查prefab是否缺乏组件"); } m_btn_add_challenge = fastComponent.FastGetComponent <UIButton>("add_challenge"); if (null == m_btn_add_challenge) { Engine.Utility.Log.Error("m_btn_add_challenge 为空,请检查prefab是否缺乏组件"); } m_trans_OpponentContent = fastComponent.FastGetComponent <Transform>("OpponentContent"); if (null == m_trans_OpponentContent) { Engine.Utility.Log.Error("m_trans_OpponentContent 为空,请检查prefab是否缺乏组件"); } m_scrollview_panel = fastComponent.FastGetComponent <UIScrollView>("panel"); if (null == m_scrollview_panel) { Engine.Utility.Log.Error("m_scrollview_panel 为空,请检查prefab是否缺乏组件"); } m_trans_gridContent = fastComponent.FastGetComponent <Transform>("gridContent"); if (null == m_trans_gridContent) { Engine.Utility.Log.Error("m_trans_gridContent 为空,请检查prefab是否缺乏组件"); } m_grid_challengeThreeContent = fastComponent.FastGetComponent <UIGrid>("challengeThreeContent"); if (null == m_grid_challengeThreeContent) { Engine.Utility.Log.Error("m_grid_challengeThreeContent 为空,请检查prefab是否缺乏组件"); } m_widget_player_01 = fastComponent.FastGetComponent <UIWidget>("player_01"); if (null == m_widget_player_01) { Engine.Utility.Log.Error("m_widget_player_01 为空,请检查prefab是否缺乏组件"); } m_widget_player_02 = fastComponent.FastGetComponent <UIWidget>("player_02"); if (null == m_widget_player_02) { Engine.Utility.Log.Error("m_widget_player_02 为空,请检查prefab是否缺乏组件"); } m_widget_player_03 = fastComponent.FastGetComponent <UIWidget>("player_03"); if (null == m_widget_player_03) { Engine.Utility.Log.Error("m_widget_player_03 为空,请检查prefab是否缺乏组件"); } m_trans_down = fastComponent.FastGetComponent <Transform>("down"); if (null == m_trans_down) { Engine.Utility.Log.Error("m_trans_down 为空,请检查prefab是否缺乏组件"); } m_btn_btn_change = fastComponent.FastGetComponent <UIButton>("btn_change"); if (null == m_btn_btn_change) { Engine.Utility.Log.Error("m_btn_btn_change 为空,请检查prefab是否缺乏组件"); } m_label_Challenge_Time = fastComponent.FastGetComponent <UILabel>("Challenge_Time"); if (null == m_label_Challenge_Time) { Engine.Utility.Log.Error("m_label_Challenge_Time 为空,请检查prefab是否缺乏组件"); } m_btn_NowChalleng = fastComponent.FastGetComponent <UIButton>("NowChalleng"); if (null == m_btn_NowChalleng) { Engine.Utility.Log.Error("m_btn_NowChalleng 为空,请检查prefab是否缺乏组件"); } m_label_NowChalleng_price = fastComponent.FastGetComponent <UILabel>("NowChalleng_price"); if (null == m_label_NowChalleng_price) { Engine.Utility.Log.Error("m_label_NowChalleng_price 为空,请检查prefab是否缺乏组件"); } m_grid_TopThreeContent = fastComponent.FastGetComponent <UIGrid>("TopThreeContent"); if (null == m_grid_TopThreeContent) { Engine.Utility.Log.Error("m_grid_TopThreeContent 为空,请检查prefab是否缺乏组件"); } m_trans_Top_01 = fastComponent.FastGetComponent <Transform>("Top_01"); if (null == m_trans_Top_01) { Engine.Utility.Log.Error("m_trans_Top_01 为空,请检查prefab是否缺乏组件"); } m_trans_Top_02 = fastComponent.FastGetComponent <Transform>("Top_02"); if (null == m_trans_Top_02) { Engine.Utility.Log.Error("m_trans_Top_02 为空,请检查prefab是否缺乏组件"); } m_trans_Top_03 = fastComponent.FastGetComponent <Transform>("Top_03"); if (null == m_trans_Top_03) { Engine.Utility.Log.Error("m_trans_Top_03 为空,请检查prefab是否缺乏组件"); } m_label_Des_label = fastComponent.FastGetComponent <UILabel>("Des_label"); if (null == m_label_Des_label) { Engine.Utility.Log.Error("m_label_Des_label 为空,请检查prefab是否缺乏组件"); } m_btn_CheckRewardBtn = fastComponent.FastGetComponent <UIButton>("CheckRewardBtn"); if (null == m_btn_CheckRewardBtn) { Engine.Utility.Log.Error("m_btn_CheckRewardBtn 为空,请检查prefab是否缺乏组件"); } m_label_check_label = fastComponent.FastGetComponent <UILabel>("check_label"); if (null == m_label_check_label) { Engine.Utility.Log.Error("m_label_check_label 为空,请检查prefab是否缺乏组件"); } m_btn_leftArrow = fastComponent.FastGetComponent <UIButton>("leftArrow"); if (null == m_btn_leftArrow) { Engine.Utility.Log.Error("m_btn_leftArrow 为空,请检查prefab是否缺乏组件"); } m_btn_rightArrow = fastComponent.FastGetComponent <UIButton>("rightArrow"); if (null == m_btn_rightArrow) { Engine.Utility.Log.Error("m_btn_rightArrow 为空,请检查prefab是否缺乏组件"); } if (null != fastComponent) { GameObject.Destroy(fastComponent); } }