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; }
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; } }
/// <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>(); }
// 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; } }
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())); }
// Use this for initialization void Start() { Debug.Log("MeetingList create"); meetingGrid = meetingGridGameObject.GetComponentInChildren<UIGrid>(); //meetingWarningGrid = meetingWarningGridGameObject.GetComponentInChildren<UIGrid>(); destroyChilds(meetingGridGameObject); destroyChilds(meetingWarningGridGameObject); initMeetingData(); }
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>(); }
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); }
// 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>(); }
void Start() { uiGrid = this.transform.parent.GetComponent<UIGrid>(); EventDelegate.Set(SellButton.onClick, () => { //出售一件装备,需要删除缓存层,需要删除服务器上的数据 OnSellClick(); });//为button添加响应事件 }
public void Init() { if (isInit == true) return; stageIconPrefab = Resources.Load("UI/Pf_Ui_StageIcon") as GameObject; grid = GetComponentInChildren<UIGrid>(); AddItem(); isInit = true; }
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; }
// 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(); }
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)); }
/// <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(); }