private void DoConstraint() { GameObject _go = Fsm.GetOwnerDefaultTarget(gameObject); if (_go == null) { return; } if (_go != null) { _Grid = _go.GetComponent <UnityEngine.UI.GridLayoutGroup>(); switch (constraint) { case Constraint.Flexible: _Grid.constraint = GridLayoutGroup.Constraint.Flexible; break; case Constraint.FixedRowCount: _Grid.constraint = GridLayoutGroup.Constraint.FixedRowCount; break; case Constraint.FixedColumnCount: _Grid.constraint = GridLayoutGroup.Constraint.FixedColumnCount; break; } } }
// Use this for initialization void Start() { inventoryPanel = GameObject.Find ("inventory Panel"); slotPanel = inventoryPanel.transform.FindChild ("slot Panel").gameObject; slotPanel2 = inventoryPanel.transform.FindChild ("slot In Game Panel").gameObject; gridLayoutGroup = slotPanel.GetComponent<GridLayoutGroup> (); gridLayoutGroup2 = slotPanel2.GetComponent<GridLayoutGroup> (); rect = gridLayoutGroup2.GetComponent<RectTransform> (); gridLayoutGroup2.cellSize = new Vector2 ((float)(rect.rect.width * 0.3), (float)(rect.rect.width * 0.3)); // gridLayoutGroup2.padding = new RectOffset((int)(rect.rect.width * 0.10),0,(int)(rect.rect.height * 0.1),0); float spacing2 = (slotPanel2.GetComponent<RectTransform> ().rect.width - (3 * gridLayoutGroup2.cellSize.x)) / 2; gridLayoutGroup2.spacing = new Vector2 (spacing2, 0); int cellCont = 10; gridLayoutGroup.cellSize = new Vector2 ((float)(rect.rect.width * 0.3), (float)(rect.rect.width * 0.3)); float spacing = (slotPanel.GetComponent<RectTransform> ().rect.width - ((cellCont/2) * gridLayoutGroup.cellSize.x)) / ((cellCont/2) - 1); gridLayoutGroup.spacing = new Vector2 (spacing, (float)(rect.rect.height * 0.30)); // gridLayoutGroup.padding = new RectOffset((int)(rect.rect.width * 0.10),0,(int)(rect.rect.height * 0.1),0); print (slotPanel2.GetComponent<RectTransform> ().rect.width); }
// int nColumns = 5; // //int nRows; // int spacing = 5; // int paddingH = 15; // int paddingV = 15; // Use this for initialization void GeneratePage(int startNumber, int pageNumber) { string str = "Level " + (difficulty == 0 ? "4x4" : (difficulty == 1 ? "6x6" : "8x8")); pages[pageNumber].transform.Find("Text").GetComponent <Text>().text = str; GameObject contentGameObject = pages[pageNumber].transform.Find("Panel").gameObject; UnityEngine.UI.GridLayoutGroup grid = contentGameObject.GetComponentInChildren <UnityEngine.UI.GridLayoutGroup>(); // grid.constraint = UnityEngine.UI.GridLayoutGroup.Constraint.FixedColumnCount; // grid.constraintCount = nColumns; // // grid.childAlignment = TextAnchor.MiddleCenter; // // grid.spacing = new Vector2(spacing, spacing); // grid.padding = new RectOffset(paddingH, paddingH, paddingV, paddingV); // // grid.cellSize = new Vector2( // (Screen.width - Screen.width * 0.3f - (nColumns - 1) * spacing - paddingH * 2) / nColumns, // //(Screen.height- Screen.height* 0.2f - (nRows-1) * spacing - paddingV * 2) / nRows // (Screen.width - Screen.width * 0.3f - (nColumns - 1) * spacing - paddingH * 2) / nColumns // ); for (int i = 0; i < nElementsPerPage; ++i) { // GameObject go = Instantiate(levelPrefab) as GameObject; contentGameObject.transform.GetChild(i).GetComponent <LevelUIScript>().SetLevel(difficulty, startNumber + i); // go.transform.GetComponent<LevelUIScript>().SetLevel(difficulty, startNumber + i); // go.transform.SetParent(contentGameObject.transform); } }
public void RandomLettersTile(List <TMPro.TextMeshProUGUI> _tiles) { List <char> _tileChar = new List <char>(); UnityEngine.UI.GridLayoutGroup gridLayoutGroup = _tiles[0].GetComponentInParent <UnityEngine.UI.GridLayoutGroup>(); gridLayoutGroup.constraintCount = 4; gridLayoutGroup.enabled = true; while (_tileChar.Count < 16) { char _tempChar = alphabet[random.Next(0, 26)]; if (!_tileChar.Contains(_tempChar)) { _tiles[_tileChar.Count].transform.parent.gameObject.SetActive(true); _tiles[_tileChar.Count].text = _tempChar.ToString(); _tiles[_tileChar.Count].GetComponentInParent <LettersTile>().assignedLetter = _tempChar; _tileChar.Add(_tempChar); } } UpdataLayout(gridLayoutGroup); #if Logs string _res = ""; for (int i = 0; i < _tileChar.Count; i++) { _res += _tileChar[i]; } Debug.LogError($"=={_res}=="); #endif }
private void DoStartAxis() { GameObject _go = Fsm.GetOwnerDefaultTarget(gameObject); if (_go == null) { return; } if (_go != null) { _Grid = _go.GetComponent <UnityEngine.UI.GridLayoutGroup>(); switch (startAxis) { case StartAxis.Horizontal: _Grid.startAxis = GridLayoutGroup.Axis.Horizontal; break; case StartAxis.Vertical: _Grid.startAxis = GridLayoutGroup.Axis.Vertical; break; } } }
static public int SetLayoutHorizontal(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif UnityEngine.UI.GridLayoutGroup self = (UnityEngine.UI.GridLayoutGroup)checkSelf(l); self.SetLayoutHorizontal(); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
static public int set_constraint(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif UnityEngine.UI.GridLayoutGroup self = (UnityEngine.UI.GridLayoutGroup)checkSelf(l); UnityEngine.UI.GridLayoutGroup.Constraint v; v = (UnityEngine.UI.GridLayoutGroup.Constraint)LuaDLL.luaL_checkinteger(l, 2); self.constraint = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
private void Start() { gridRect = GetComponentInParent<RectTransform>(); gridCanvas = GetComponentInParent<Canvas>(); gridLayout = GetComponentInParent<GridLayoutGroup>(); gridRect.pivot = new Vector2(0, 0); gridRect.position = new Vector3(terrainMesh.transform.position.x, 6.0f, terrainMesh.transform.position.z); gridRect.anchorMin = new Vector2(terrainMesh.transform.position.x, terrainMesh.transform.position.z); gridRect.anchorMax = new Vector2(terrainMesh.terrainData.size.x, terrainMesh.terrainData.size.z); gridLayout.CalculateLayoutInputHorizontal(); Debug.Log(string.Format("Origin: {0}, Size: {1}, Cell size: {2}\n", gridRect.position.ToString(), gridRect.rect.size.ToString(), gridLayout.cellSize)); buttonTemplate = GetComponentInChildren<Button>(); for (int y = 0; y < gridRect.rect.y; y++) { for (int x = 0; x < gridRect.rect.x; x++) { Vector3 pos = new Vector3(x, 0, y); // * spacing; Button b = (Button)Instantiate(buttonTemplate, pos, Quaternion.identity); //b.gameObject.AddComponent<LayoutElement>(); //b.name = "Button " + x.ToString() + "," + y.ToString(); //b.GetComponentInChildren<Text>().text = b.name; gridLayout.SetLayoutHorizontal(); } } }
private void DoStartCorner() { GameObject _go = Fsm.GetOwnerDefaultTarget(gameObject); if (_go == null) { return; } if (_go != null) { _Grid = _go.GetComponent <UnityEngine.UI.GridLayoutGroup>(); switch (startCorner) { case StartCorner.UpperLeft: _Grid.startCorner = GridLayoutGroup.Corner.UpperLeft; break; case StartCorner.UpperRight: _Grid.startCorner = GridLayoutGroup.Corner.UpperRight; break; case StartCorner.LowerLeft: _Grid.startCorner = GridLayoutGroup.Corner.LowerLeft; break; case StartCorner.LowerRight: _Grid.startCorner = GridLayoutGroup.Corner.LowerRight; break; } } }
void Start () { gridLayoutGroup = GetComponent<GridLayoutGroup> (); rect = GetComponent<RectTransform> (); gridLayoutGroup.cellSize = new Vector2 (rect.rect.height, rect.rect.height); cellCount = GetComponentsInChildren<RectTransform> ().Length; }
void UpdataLayout(UnityEngine.UI.GridLayoutGroup _gridLayoutGroup) { _gridLayoutGroup.CalculateLayoutInputHorizontal(); _gridLayoutGroup.CalculateLayoutInputVertical(); _gridLayoutGroup.SetLayoutHorizontal(); _gridLayoutGroup.SetLayoutVertical(); _gridLayoutGroup.enabled = false; }
void Start (){ cellCount = transform.childCount; gridLayoutGroup = GetComponent<GridLayoutGroup> (); rect = GetComponent<RectTransform> (); resizeCell(); }
void AdjustGridLayout() { GameObject gridTilesContainer = GameObject.FindGameObjectWithTag("GameTiles"); UnityEngine.UI.GridLayoutGroup layoutGroup = gridTilesContainer.GetComponent <UnityEngine.UI.GridLayoutGroup>(); layoutGroup.constraint = UnityEngine.UI.GridLayoutGroup.Constraint.FixedColumnCount; layoutGroup.constraintCount = difficultyScript.GetGridSettings().columns; }
private void Awake() { infectedChipsOrder = new List<int>(InfectedChipsNumber); infectedChips = new List<InfectedChip>(InfectedChipsNumber); grid = GetComponent<GridLayoutGroup>(); gridPoints = grid.GetComponentsInChildren<RectTransform>().ToList(); }
static public int set_startAxis(IntPtr l) { UnityEngine.UI.GridLayoutGroup o = (UnityEngine.UI.GridLayoutGroup)checkSelf(l); UnityEngine.UI.GridLayoutGroup.Axis v; checkEnum(l, 2, out v); o.startAxis = v; return(0); }
static public int set_constraint(IntPtr l) { UnityEngine.UI.GridLayoutGroup o = (UnityEngine.UI.GridLayoutGroup)checkSelf(l); UnityEngine.UI.GridLayoutGroup.Constraint v; checkEnum(l, 2, out v); o.constraint = v; return(0); }
static public int set_spacing(IntPtr l) { UnityEngine.UI.GridLayoutGroup o = (UnityEngine.UI.GridLayoutGroup)checkSelf(l); UnityEngine.Vector2 v; checkType(l, 2, out v); o.spacing = v; return(0); }
void Start() { PlayerControl = GameObject.FindObjectOfType<PlayerObjectsController> (); grid = GetComponent<GridLayoutGroup>(); rect = GetComponent<RectTransform>(); scrollRect = GetComponentInParent<ScrollRect>(); // auto adjust the width of the grid to have space for all the childs rect.sizeDelta = new Vector2((transform.childCount + 2f) * grid.cellSize.x + (transform.childCount - 1f) * grid.spacing.x, rect.sizeDelta.y); }
private void Start() { itemAmount = transform.childCount; grid = GetComponent<GridLayoutGroup>(); rect = GetComponentInChildren<RectTransform>().rect; float xSize = rect.width / itemAmount; float ySize = rect.height / itemAmount; xSize = rect.width; grid.cellSize = new Vector2(xSize, ySize); }
void Start() { m_ScrollRect = this.GetComponent<ScrollRect>(); m_Intertia = m_ScrollRect.decelerationRate; m_ScrollRect.inertia = false; m_Grid = m_ScrollRect.content.GetComponent<GridLayoutGroup>(); m_ContentRect = m_ScrollRect.content.GetComponent<RectTransform>(); }
protected void initScroll() { myScrollRect = GetComponent<ScrollRect> (); myscrollBar = myScrollRect.horizontalScrollbar; ((SkyScrollRect)myScrollRect).mySkyOnEndDrag = new SkyScrollRect.SkyOnEndDrag (onEndDrag); ((SkyScrollRect)myScrollRect).mySkyOnBeginDrag = new SkyScrollRect.SkyOnBeginDrag (onBeginDrag); ((SkyScrollRect)myScrollRect).mySkyOnDrag = new SkyScrollRect.SkyOnDrag (onDrag); myScrollList = GameObject.Find (SCROLL_LIST); myGridLayoutGroup = myScrollList.GetComponent<GridLayoutGroup> (); }
void Awake() { grid = GetComponent<GridLayoutGroup>(); rect = GetComponent<RectTransform>(); scrollRect = GetComponentInParent<ScrollRect>(); rect.localPosition = new Vector3(rect.localPosition.x, buttonHeight * 2 + (buttonHeight * active), 0); done = true; rect.sizeDelta = new Vector2(rect.sizeDelta.y, (transform.childCount + 2f) * grid.cellSize.y + (transform.childCount - 1f) * grid.spacing.y); buttonHeight = grid.spacing.y + grid.cellSize.y; }
protected virtual void InitLayoutInfo() { gridLayout = GetComponentInChildren<GridLayoutGroup>() ; layoutRect = gridLayout.GetComponent<RectTransform>() ; if(gridLayout == null) { Debug.LogWarning ("Cannot Adjust ScrollView Without Grid Component ") ; } }
public virtual void Start() { fieldMatrix = new Cell[fieldWidth, fieldHeight + upperInvisibleRows]; myRT = GetComponent<RectTransform>(); myGrid = GetComponent<GridLayoutGroup>(); RecalculateCellSize(); CreatingFieldMatrix(); }
// Use this for initialization void Start() { //general setup menu = GetComponentInParent<Menu>(); toDraw = true; if (options == null) options = new List<MenuViewOptionBasic>(); GetComponentsInChildren<MenuViewOptionBasic>(options); textboxes = new List<GameObject>(); //Setup view viewObject = Instantiate(horizontalViewPrefab); viewObject.transform.SetParent(transform); canvas = viewObject.GetComponent<Canvas>(); canvas.worldCamera = drawCamera; canvas.planeDistance = 1; if (fillScreen) { size.x = drawCamera.pixelWidth; } layoutText = viewObject.transform.Find("TextGroup").GetComponentInChildren<GridLayoutGroup>(); layoutText.transform.GetComponent<RectTransform>().anchoredPosition = new Vector2(offset.x, offset.y); layoutText.GetComponent<RectTransform>().sizeDelta = new Vector2(drawCamera.pixelWidth, drawCamera.pixelHeight); layoutText.childAlignment = viewAnchor; layoutText.cellSize = new Vector2(size.x / options.Count, size.y); //Setup textboxes if (options.Count > 0) { GameObject curTextbox; Text curText; for (int i = 0; i < options.Count; i++) { curTextbox = Instantiate<GameObject>(menuTextPrefab); curTextbox.transform.SetParent(layoutText.transform,false); curText = curTextbox.GetComponent<Text>(); curText.text = options[i].optionText; curText.font = textFont; if (i == menu.CurOption) { curOption = i; curText.color = highlightedColor; } else { curText.color = unhighlightedColor; } textboxes.Add(curTextbox); } } //Setup background Image background = viewObject.GetComponentInChildren<Image>(); GameObject backObj = background.gameObject; background.sprite = backgroundImage; background.color = backgroundColor; backObj.GetComponent<RectTransform>().sizeDelta = new Vector2(size.x, size.y); backObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(offset.x, offset.y); layoutBack = backObj.transform.parent.GetComponent<GridLayoutGroup>(); layoutBack.cellSize = new Vector2(size.x,size.y); layoutBack.GetComponent<RectTransform>().sizeDelta = new Vector2(drawCamera.pixelWidth, drawCamera.pixelHeight); layoutBack.GetComponent<RectTransform>().anchoredPosition = new Vector2(offset.x, offset.y); layoutBack.childAlignment = viewAnchor; //background.set }
static public int get_constraintCount(IntPtr l) { try { UnityEngine.UI.GridLayoutGroup self = (UnityEngine.UI.GridLayoutGroup)checkSelf(l); pushValue(l, self.constraintCount); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int CalculateLayoutInputHorizontal(IntPtr l) { try { UnityEngine.UI.GridLayoutGroup self = (UnityEngine.UI.GridLayoutGroup)checkSelf(l); self.CalculateLayoutInputHorizontal(); return(0); } catch (Exception e) { return(error(l, e)); } }
static public int SetLayoutVertical(IntPtr l) { try { UnityEngine.UI.GridLayoutGroup self = (UnityEngine.UI.GridLayoutGroup)checkSelf(l); self.SetLayoutVertical(); return(0); } catch (Exception e) { return(error(l, e)); } }
static public int get_startAxis(IntPtr l) { try { UnityEngine.UI.GridLayoutGroup self = (UnityEngine.UI.GridLayoutGroup)checkSelf(l); pushEnum(l, (int)self.startAxis); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int get_startCorner(IntPtr l) { try { UnityEngine.UI.GridLayoutGroup self = (UnityEngine.UI.GridLayoutGroup)checkSelf(l); pushValue(l, true); pushEnum(l, (int)self.startCorner); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int SetLayoutHorizontal(IntPtr l) { try { UnityEngine.UI.GridLayoutGroup self = (UnityEngine.UI.GridLayoutGroup)checkSelf(l); self.SetLayoutHorizontal(); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int CalculateLayoutInputVertical(IntPtr l) { try { UnityEngine.UI.GridLayoutGroup self = (UnityEngine.UI.GridLayoutGroup)checkSelf(l); self.CalculateLayoutInputVertical(); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int get_spacing(IntPtr l) { try { UnityEngine.UI.GridLayoutGroup self = (UnityEngine.UI.GridLayoutGroup)checkSelf(l); pushValue(l, true); pushValue(l, self.spacing); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int get_spacing(IntPtr l) { try { UnityEngine.UI.GridLayoutGroup self = (UnityEngine.UI.GridLayoutGroup)checkSelf(l); pushValue(l, self.spacing); return(1); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int CalculateLayoutInputVertical(IntPtr l) { try { UnityEngine.UI.GridLayoutGroup self = (UnityEngine.UI.GridLayoutGroup)checkSelf(l); self.CalculateLayoutInputVertical(); return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int SetLayoutHorizontal(IntPtr l) { try { UnityEngine.UI.GridLayoutGroup self = (UnityEngine.UI.GridLayoutGroup)checkSelf(l); self.SetLayoutHorizontal(); return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int get_startCorner(IntPtr l) { try { UnityEngine.UI.GridLayoutGroup self = (UnityEngine.UI.GridLayoutGroup)checkSelf(l); pushEnum(l, (int)self.startCorner); return(1); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
// Use this for initialization void Start() { ss = GetComponentInParent <ScrollRectSize>(); if (ss != null) { ss.AddItem(this); } node = transform.Find("Image").GetComponent <RectTransform>(); rt = transform.GetComponent <RectTransform>(); glg = ss.content.GetComponent <UnityEngine.UI.GridLayoutGroup>(); }
private void Awake() { if (single == null) { single = this; } m_SlotGroupGrid = m_SlotGroupTransform.GetComponent <UnityEngine.UI.GridLayoutGroup>(); for (int i = 0; i < m_Slot.Length; ++i) { m_Slot[i].SetActive(false); } }
static int QPYX_SetLayoutVertical_YXQP(IntPtr L_YXQP) { try { ToLua.CheckArgsCount(L_YXQP, 1); UnityEngine.UI.GridLayoutGroup QPYX_obj_YXQP = (UnityEngine.UI.GridLayoutGroup)ToLua.CheckObject <UnityEngine.UI.GridLayoutGroup>(L_YXQP, 1); QPYX_obj_YXQP.SetLayoutVertical(); return(0); } catch (Exception e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP)); } }
static public int set_startCorner(IntPtr l) { try { UnityEngine.UI.GridLayoutGroup self = (UnityEngine.UI.GridLayoutGroup)checkSelf(l); UnityEngine.UI.GridLayoutGroup.Corner v; checkEnum(l, 2, out v); self.startCorner = v; return(0); } catch (Exception e) { return(error(l, e)); } }
static public int set_spacing(IntPtr l) { try { UnityEngine.UI.GridLayoutGroup self = (UnityEngine.UI.GridLayoutGroup)checkSelf(l); UnityEngine.Vector2 v; checkType(l, 2, out v); self.spacing = v; return(0); } catch (Exception e) { return(error(l, e)); } }
static public int set_constraintCount(IntPtr l) { try { UnityEngine.UI.GridLayoutGroup self = (UnityEngine.UI.GridLayoutGroup)checkSelf(l); int v; checkType(l, 2, out v); self.constraintCount = v; return(0); } catch (Exception e) { return(error(l, e)); } }
// Use this for initialization public void Init() { m_UIItemList = new List<ItemUIControl>(); int i=0; foreach(ItemUIControl uiItem in GetComponentsInChildren<ItemUIControl>()) { uiItem.ItemIndexInPackge = i; m_UIItemList.Add(uiItem); ++i; } m_ItemLayout = GetComponent<GridLayoutGroup>(); m_PlayerItemList = DungonManager.Inst.GetPlayerItemList(); }
// Use this for initialization void Start() { speedMod = 2; //colorPoolLayout = colorPool.GetComponent<LayoutGroup>(); colorPool = GameObject.Find("Color Buttons"); colorPoolLayout = colorPool.GetComponent<GridLayoutGroup>(); colors = colorPool.GetComponentsInChildren<Image>(); buttonSizes = new Vector2[colors.Length]; int i = 0; foreach (Image c in colors) { buttonSizes[i].x = c.rectTransform.position.x; buttonSizes[i].y = c.rectTransform.position.x + i++; } }
public override void OnStartLocalPlayer() { base.OnStartLocalPlayer(); Debug.Log("A local player started"); isALocalPlayer = true; cardLayout = GameObject.Find("PHONECARDLAYOUT").GetComponent<GridLayoutGroup>(); timer = GameObject.Find("TIMER").GetComponent<Text>(); artguy = composer = producer = scoper = false; /* GameObject card = Instantiate(personCardPrefab); //card.GetComponent<PhoneUIPersonCard>().UseCard(CardGameManager.instance.cardLib.GetPerson(id)); card.GetComponent<PhoneUIPersonCard>().SetGray(false); card.transform.SetParent(cardLayout.transform, false); */ }
public void Init () { m_Rect = GetComponent<RectTransform> (); m_Grid = GetComponent<GridLayoutGroup> (); List_Member.Add (Default_Member.GetComponent<UI_List_Member>()); for (int i = 1; i < List_Count; i++) { GameObject ob = (GameObject)Instantiate (Default_Member,Default_Member.transform.position,Default_Member.transform.rotation); ob.transform.SetParent (Default_Member.transform.parent); ob.name = "Member_" + i.ToString (); ob.transform.localScale = Default_Member.transform.localScale; List_Member.Add (ob.GetComponent<UI_List_Member>()); } for (int i = 0; i < List_Count; i++) { List_Member [i].ID = i; if (List_Member [i].Order) List_Member [i].Order.text = (i+1).ToString(); } //List_Member = GetComponentsInChildren<UI_List_Member> (); Vector2 size = new Vector2(m_Rect.sizeDelta.x,m_Grid.padding.top + (m_Grid.cellSize.y + m_Grid.spacing.y) * List_Count); m_Rect.sizeDelta = size; }
public void SetupGrid(int gridSetupSelection) { foreach (Transform button in buttonList) { button.gameObject.SetActive(false); } gridLayout = GetComponent<GridLayoutGroup>(); int gridSetupCount; switch (gridSetupSelection) { case 0: // OCTANT gridSet = "Octant"; gridSetupCount = octantGridCount; gridLayout.cellSize = octantGridSize; gridLayout.spacing = octantGridSpacing; gridLayout.constraintCount = 10; for (int i = 0; i < gridSetupCount; i++) { buttonList [i].gameObject.SetActive(true); string buttonText = buttonList [i].GetComponentInChildren<Text>().text = "System " + (i + 1); } break; case 1: // SUBSECTOR gridSet = "Subsector"; gridSetupCount = subsectorGridCount; gridLayout.cellSize = subsectorGridSize; gridLayout.spacing = subsectorGridSpacing; gridLayout.constraintCount = 20; for (int i = 0; i < gridSetupCount; i++) { buttonList [i].gameObject.SetActive(true); string buttonText = buttonList [i].GetComponentInChildren<Text>().text = "System " + (i + 1); } break; default: break; } }
void Start() { /* Get the reference from the RectTransform component within this game object. */ rectTransform = gameObject.GetComponent<RectTransform>(); //Get reference from a GridLayoutGroup from this game object. gridLayoutGroup = gameObject.GetComponent<GridLayoutGroup>(); //Assign value of border game object and its script. border = GameObject.Find("Border"); scriptBorder = border.GetComponent<ScriptBorder>(); //Assign value to the panelLog and scriptPanelLog. panelLog = GameObject.Find("PanelLog"); scriptPanelLog = panelLog.GetComponent<ScriptPanelLog>(); //Assign value to player and scriptPlayer,. player = GameObject.Find("Player"); scriptPlayer = player.GetComponent<ScriptPlayer>(); }
private IEnumerable<KeyValuePair<MapPosition, TileController>> InitGrid(GridLayoutGroup grid, int numberOfRows, int numberOfColumns, Const.Team team, Action<MapPosition, bool> onTileClick) { grid.constraint = GridLayoutGroup.Constraint.FixedColumnCount; grid.constraintCount = numberOfColumns; for (int i = 0; i < numberOfRows; i++) { for (int j = 0; j < numberOfColumns; j++) { var mapPosition = new MapPosition(j, i, team); var tile = Instantiate(tilePrefab) as GameObject; tile.transform.SetParent(grid.transform); tile.transform.localScale = Vector3.one; tile.transform.localEulerAngles = Vector3.zero; tile.transform.localPosition = Vector3.zero; var tileController = tile.GetComponent<TileController>(); tileController.Init(mapPosition, onTileClick); yield return new KeyValuePair<MapPosition, TileController>(mapPosition, tileController); } } }
public void Start() { GameObject parentPanel = transform.parent.gameObject; buttonHolder = transform.FindChild("Viewport").FindChild("Content").FindChild("ButtonHolder").GetComponent<GridLayoutGroup>(); menuController = transform.parent.parent.GetComponent<CharacterCreate>(); UIIcon = parentPanel.transform.FindChild("CurrentPerk").GetComponent<Image>(); UIName = UIIcon.transform.GetChild(0).GetComponentInChildren<Text>(); UIDescription = parentPanel.transform.FindChild("DescriptionPanel").GetChild(0).GetComponent<Text>(); perks = Resources.LoadAll<Perk>("Data/Perks").Where(p => p.IsStartPerk).ToList(); foreach (Perk perk in perks.OrderBy(p => p.Name)) { Button button = GameObject.Instantiate<Button>(buttonPrefab); if (perk.Icon != null) button.GetComponent<Image>().sprite = perk.Icon; else button.GetComponentInChildren<Text>().text = perk.Name; button.transform.SetParent(buttonHolder.transform, false); Perk temp = perk; button.onClick.AddListener(() => { PerkClicked(temp); }); } }
void Start() { this.behave = GameObject.FindGameObjectWithTag("Behaviour").GetComponent<GameBehavior>(); RectTransform headRect = heads.GetComponent<RectTransform> (); maxSize = headRect.rect.height; maxCollumn = 6; amountCollumn = Mathf.Floor(behave.enemiesKilled / 11) + 1; if (amountCollumn > maxCollumn) amountCollumn = maxCollumn; float imageSize; if (behave.enemiesKilled == 0) { this.coinsPerEnemy = 0; imageSize = 0; } else { imageSize = (headRect.rect.width / behave.enemiesKilled) * amountCollumn; //define tamanho de cada imagem sendo: area_total/total_de_inimigos if(imageSize > maxSize) imageSize = maxSize; this.coinsPerEnemy = (behave.getEarnedCoins () / behave.enemiesKilled); } headsGrid = heads.GetComponent<GridLayoutGroup> (); headsGrid.cellSize = new Vector2(imageSize,imageSize); if (behave.totalEnemies == 0) this.totalEnimies.text = "∞"; else this.totalEnimies.text = behave.totalEnemies.ToString (); if (this.coinsPerEnemy < 1) coinsPerEnemy = 1; this.startIncrementCoins (); }
private void CreateLayoutGroup() { if (isVertical) { if (isHorizontal) { grid = contextMenuRT.gameObject.AddComponent<GridLayoutGroup>(); //type = TYPE_GRID; grid.spacing = new Vector2(buttonsSpacingX,buttonsSpacingY); grid.padding = new RectOffset(buttonsPaddingX, buttonsPaddingX, buttonsPaddingY, buttonsPaddingY); grid.cellSize = new Vector2(buttonsWidth,buttonsHeight); return; } vertical = contextMenuRT.gameObject.AddComponent<VerticalLayoutGroup>(); //type = TYPE_VERTICAL; vertical.spacing = buttonsSpacingY; vertical.padding = new RectOffset(buttonsPaddingX, buttonsPaddingX, buttonsPaddingY, buttonsPaddingY); vertical.childForceExpandWidth = true; vertical.childForceExpandHeight = false; return; } if (isHorizontal) { horizontal = contextMenuRT.gameObject.AddComponent<HorizontalLayoutGroup>(); //type = TYPE_HORIZONTAL; vertical.spacing = buttonsSpacingX; horizontal.padding = new RectOffset(buttonsPaddingX, buttonsPaddingX, buttonsPaddingY, buttonsPaddingY); horizontal.childForceExpandWidth = true; horizontal.childForceExpandHeight = false; return; } }
// Use this for initialization private void Start() { this.animationState = InventoryAnimationStates.NONE; this.layoutGroup = this.gameObject.GetComponent<GridLayoutGroup>(); this.canvasGroup = this.gameObject.GetComponent<CanvasGroup>(); var responsiveUtil = this.gameObject.GetComponent<ResponsiveUtil>(); if(responsiveUtil != null) responsiveUtil.CalculateSize(); this.InitInventoryPanel(); this.PopulateSlots(); this.PopulateItems(); }
/// <summary> /// Creates the options container. /// </summary> protected void CreateOptionsContainer() { // Create new game object this.m_OptionsContGameObject = new GameObject("Options Grid", typeof(RectTransform), typeof(GridLayoutGroup)); this.m_OptionsContGameObject.layer = this.gameObject.layer; this.m_OptionsContGameObject.transform.SetParent(this.transform, false); this.m_OptionsContGameObject.transform.SetAsFirstSibling(); // Get the rect transform this.m_OptionsContRect = this.m_OptionsContGameObject.GetComponent<RectTransform>(); this.m_OptionsContRect.sizeDelta = new Vector2(0f, 0f); this.m_OptionsContRect.anchorMin = new Vector2(0f, 0f); this.m_OptionsContRect.anchorMax = new Vector2(1f, 1f); this.m_OptionsContRect.anchoredPosition = new Vector2(0f, 0f); // Get the grid layout group this.m_OptionsContGrid = this.m_OptionsContGameObject.GetComponent<GridLayoutGroup>(); }
void Start() { gridLayoutGroup = gameObject.GetComponent<GridLayoutGroup>(); explanationHashSet = new HashSet<string>(); }
private void Awake() { achievementList = Achievements.GetAchievements(); gridLayout = GetComponent<GridLayoutGroup>(); }
/// <summary> /// Set the width of the line. /// </summary> /// <param name="lineWidth">Line width.</param> public void SetWidthGrid (float lineWidth, GridLayoutGroup contentsGrid){ this.lineWidth = lineWidth; contentsGridLayout = contentsGrid; }
void Start() { // Re-map all this ascii because I hate myself. Nothing to see here. indices = new Dictionary<char, int>(); indices.Add('a', 0); indices.Add('b', 1); indices.Add('c', 2); indices.Add('d', 3); indices.Add('e', 4); indices.Add('f', 5); indices.Add('g', 6); indices.Add('h', 7); indices.Add('i', 8); indices.Add('j', 9); indices.Add('k', 10); indices.Add('l', 11); indices.Add('m', 12); indices.Add('n', 13); indices.Add('o', 14); indices.Add('p', 15); indices.Add('q', 16); indices.Add('r', 17); indices.Add('s', 18); indices.Add('t', 19); indices.Add('u', 20); indices.Add('v', 21); indices.Add('w', 22); indices.Add('x', 23); indices.Add('y', 24); indices.Add('z', 25); indices.Add('1', 26); indices.Add('2', 27); indices.Add('3', 28); indices.Add('4', 29); indices.Add('5', 30); indices.Add('6', 31); indices.Add('7', 32); indices.Add('8', 33); indices.Add('9', 34); indices.Add('0', 35); indices.Add('!', 36); indices.Add('@', 37); indices.Add('#', 38); indices.Add('$', 39); indices.Add('%', 40); indices.Add('^', 41); indices.Add('&', 42); indices.Add('*', 43); indices.Add('(', 44); indices.Add(')', 45); indices.Add('[', 46); indices.Add(']', 47); indices.Add('/', 48); indices.Add('\\',49); indices.Add('+', 50); indices.Add('-', 51); indices.Add('=', 52); indices.Add('?', 53); indices.Add('.', 54); indices.Add(',', 55); indices.Add('\'',56); indices.Add('"', 57); indices.Add(':', 58); indices.Add(';', 59); indices.Add('|', 60); indices.Add(' ', 61); indices.Add('\n',61); indices.Add('\t',61); // Check for a scrolling text controller. scrollController = GetComponent<ScrollingText>(); // Load each sprite on the sheet so we can reference it with our silly map. sprites = Resources.LoadAll<Sprite>("HUDElements/Font"); // Init our letter prefab. letterPrefab = Resources.Load<GameObject>("Prefabs/TextSystem/TextElement"); // Init our list letterObjects = new List<GameObject>(); // Get and check the text component txt = GetComponent<Text>(); if (txt == null) { Debug.LogError("No Text component found on object marked as text!"); Destroy(this); // Delete this script for safety. } // Prepare the object for sprite text. layout = gameObject.AddComponent<GridLayoutGroup>(); layout.cellSize = new Vector2(8 * sizeMultiplierX * kerningMultiplier, 16 * sizeMultiplierY * leadingMultiplier); layout.spacing = new Vector2(spacingX, spacingY); // Disappearify the default text in the hackiest way possible so as to conserve its other attributes for use with sprite text. txt.material = Resources.Load<Material>("HUDElements/FontBeGone"); // Populate initial text RefreshText(); }
void setReferences() { gridLayout = GetComponent<GridLayoutGroup>(); canvas = GetComponentInParent<Canvas>(); selector = GetComponentInParent<PhraseSelector>(); }