protected override void Awake() { base.Awake(); _rect = GetComponent<RectTransform>(); _layoutElement = GetComponent<LayoutElement>(); }
// ----------------------- void OnEnable() { if (this.target == null) { this.target = this.GetComponent <UnityEngine.UI.LayoutElement>(); } }
public void Layout() { RectTransform rt = GetComponent <RectTransform>(); countPerRow = (int)(rt.rect.width / (cellSize.x + spacing.x)); if (countPerRow < 1) { countPerRow = 1; } int n = rt.childCount; int j = 0; for (int i = 0; i < n; i++) { RectTransform childRT = rt.GetChild(i) as RectTransform; if (childRT.gameObject.activeSelf) { UnityEngine.UI.LayoutElement el = childRT.GetComponent <UnityEngine.UI.LayoutElement>(); if (el != null && el.ignoreLayout) { continue; } Vector2 pos = CalcPosition(j); childRT.anchoredPosition = pos; j++; } } }
protected override void Start() { base.Start(); textElement = GetComponentInChildren<Text>(); layoutElement = GetComponent<LayoutElement>(); slider = GameObject.Find("ButtonTextSlider").GetComponent<Slider>(); }
static public int set_ignoreLayout(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.LayoutElement self = (UnityEngine.UI.LayoutElement)checkSelf(l); bool v; checkType(l, 2, out v); self.ignoreLayout = 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 }
//Adopted from LayoutGroup public virtual void CalculateLayoutInputHorizontal() { m_RectChildren.Clear(); for (int i = 0; i < rectTransform.childCount; i++) { RectTransform rect = rectTransform.GetChild(i) as RectTransform; if (rect == null) continue; ILayoutIgnorer ignorer = rect.GetComponent(typeof(ILayoutIgnorer)) as ILayoutIgnorer; if (rect.gameObject.activeInHierarchy && !(ignorer != null && ignorer.ignoreLayout)) m_RectChildren.Add(rect); } //Layout element for holding our overriden minimum width if (m_layout == null) { m_layout = GetComponent<LayoutElement>(); if (m_layout == null) { m_layout = gameObject.AddComponent<LayoutElement>(); } } m_Tracker.Clear(); }
// Use this for initialization void Start() { lay=this.gameObject.GetComponent<LayoutElement>(); imagen=this.gameObject.GetComponent<Image>(); lay.preferredWidth=imagen.sprite.rect.width; lay.preferredHeight=imagen.sprite.rect.height; }
//TODO: Change this to accept a Vector2(x,y) for size, so we can change width and height. Currently, we can only change height. /// <summary> /// Currently used to resize a Unity UI LayoutElement Vertically. /// </summary> /// <param name="aElement">LayoutElement to resize</param> /// <param name="aSize">How tall should it become?</param> /// <param name="aTime">How long should it take?</param> /// <param name="aCurve">How should it look?</param> /// <param name="aCallback">What should happen after we're done, if anything?</param> public void ResizeLayoutElement(UnityEngine.UI.LayoutElement aElement, float aSize, float aTime, AnimationCurve aCurve = null, System.Action aCallback = null) { if (!RegisterObject(aElement)) { return; } StartCoroutine(CoResizeElementVertical(aElement, aSize, aTime, aCurve, aCallback)); }
static public int set_flexibleWidth(IntPtr l) { UnityEngine.UI.LayoutElement o = (UnityEngine.UI.LayoutElement)checkSelf(l); float v; checkType(l, 2, out v); o.flexibleWidth = v; return(0); }
static public int set_ignoreLayout(IntPtr l) { UnityEngine.UI.LayoutElement o = (UnityEngine.UI.LayoutElement)checkSelf(l); bool v; checkType(l, 2, out v); o.ignoreLayout = v; return(0); }
static public int set_minHeight(IntPtr l) { UnityEngine.UI.LayoutElement o = (UnityEngine.UI.LayoutElement)checkSelf(l); float v; checkType(l, 2, out v); o.minHeight = v; return(0); }
void Start () { le = GetComponent<LayoutElement>(); if (setMinWidth) le.minWidth = target.rect.width; if (setMinHeight) le.minHeight = target.rect.height; }
static public int get_minHeight(IntPtr l) { try { UnityEngine.UI.LayoutElement self = (UnityEngine.UI.LayoutElement)checkSelf(l); pushValue(l, self.minHeight); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int CalculateLayoutInputHorizontal(IntPtr l) { try { UnityEngine.UI.LayoutElement self = (UnityEngine.UI.LayoutElement)checkSelf(l); self.CalculateLayoutInputHorizontal(); return(0); } catch (Exception e) { return(error(l, e)); } }
static int DOPreferredSize(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 4); UnityEngine.UI.LayoutElement arg0 = (UnityEngine.UI.LayoutElement)LuaScriptMgr.GetUnityObject(L, 1, typeof(UnityEngine.UI.LayoutElement)); Vector2 arg1 = LuaScriptMgr.GetVector2(L, 2); float arg2 = (float)LuaScriptMgr.GetNumber(L, 3); bool arg3 = LuaScriptMgr.GetBoolean(L, 4); DG.Tweening.Tweener o = DG.Tweening.ShortcutExtensions46.DOPreferredSize(arg0, arg1, arg2, arg3); LuaScriptMgr.PushObject(L, o); return(1); }
static public int CalculateLayoutInputVertical(IntPtr l) { try { UnityEngine.UI.LayoutElement self = (UnityEngine.UI.LayoutElement)checkSelf(l); self.CalculateLayoutInputVertical(); return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int get_ignoreLayout(IntPtr l) { try { UnityEngine.UI.LayoutElement self = (UnityEngine.UI.LayoutElement)checkSelf(l); pushValue(l, true); pushValue(l, self.ignoreLayout); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int get_minWidth(IntPtr l) { try { UnityEngine.UI.LayoutElement self = (UnityEngine.UI.LayoutElement)checkSelf(l); pushValue(l, self.minWidth); return(1); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int CalculateLayoutInputVertical(IntPtr l) { try { UnityEngine.UI.LayoutElement self = (UnityEngine.UI.LayoutElement)checkSelf(l); self.CalculateLayoutInputVertical(); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
public void Setup(IAssignedPanel model, CardManager cardManager, PanelManager panelManager, DynamicPopup popups) { this.model = model; this.cardManager = cardManager; this.panelManager = panelManager; this.popups = popups; cardPanelUI.headerIcon.sprite = model.GetIcon(); initialTitle = model.GetTitle(); cardPanelUI.SetHeaderText(model.GetTitle()); cardPanelUI.closeButton.onClick.AddListener(DeletePanel); cardPanelUI.headerTextInput.onEndEdit.AddListener(OnEditTitle); foreach (var slot in model.GetDecks()) { GameObject newSlotObj = Instantiate(cardSlotPrefab, cardPanelUI.deckParent); CardDeck newslot = newSlotObj.GetComponentInChildren <CardDeck>(); newslot.Setup(slot); newslot.SetColor(model.GetColor()); string propName = slot.GetPropertyName(); if (propName != null) { cardSlotForProperty[propName] = newSlotObj; } } cardPanelUI.headerBackground.color = model.GetColor(); GameObject propsObject = Instantiate(propertyFieldsPrefab, cardPanelUI.fieldsParent); propsObject.transform.SetAsFirstSibling(); propsLayoutElement = cardPanelUI.fieldsParent.GetComponent <UnityEngine.UI.LayoutElement>(); cardPropertiesUX = propsObject.GetComponent <BehaviorUX.CardPropertiesUX>(); cardPropertiesUX.Setup(model.GetBehavior()?.GetProperties()); cardPropertiesUX.onValueChanged += (type) => { UpdateSlotsVisibility(); }; cardPropertiesUX.gameObject.SetActive(cardPropertiesUX.HasAnyProps()); parentRect = transform.parent.GetComponent <RectTransform>(); // I don't like this. if (GetModel().GetId() == BehaviorCards.GetMiscPanelId()) { cardPanelUI.closeButton.gameObject.SetActive(false); } UpdateSlotsVisibility(); }
static public int set_minWidth(IntPtr l) { try { UnityEngine.UI.LayoutElement self = (UnityEngine.UI.LayoutElement)checkSelf(l); float v; checkType(l, 2, out v); self.minWidth = v; return(0); } catch (Exception e) { return(error(l, e)); } }
static public int set_ignoreLayout(IntPtr l) { try { UnityEngine.UI.LayoutElement self = (UnityEngine.UI.LayoutElement)checkSelf(l); bool v; checkType(l, 2, out v); self.ignoreLayout = v; return(0); } catch (Exception e) { return(error(l, e)); } }
static public int set_layoutPriority(IntPtr l) { try { UnityEngine.UI.LayoutElement self = (UnityEngine.UI.LayoutElement)checkSelf(l); int v; checkType(l, 2, out v); self.layoutPriority = v; return(0); } catch (Exception e) { return(error(l, e)); } }
protected override void Awake() { base.Awake(); base.transition = Transition.None; base.toggleTransition = ToggleTransition.None; this.m_Accordion = this.gameObject.GetComponentInParent<UIAccordion>(); this.m_RectTransform = this.transform as RectTransform; this.m_LayoutElement = this.gameObject.GetComponent<LayoutElement>(); this.onValueChanged.AddListener(OnValueChanged); if (this.isOn) this.m_Accordion.activeAccrodionElement = this.m_RectTransform; this.onValueChanged.AddListener(OnValueChanged); }
static int QPYX_CalculateLayoutInputVertical_YXQP(IntPtr L_YXQP) { try { ToLua.CheckArgsCount(L_YXQP, 1); UnityEngine.UI.LayoutElement QPYX_obj_YXQP = (UnityEngine.UI.LayoutElement)ToLua.CheckObject <UnityEngine.UI.LayoutElement>(L_YXQP, 1); QPYX_obj_YXQP.CalculateLayoutInputVertical(); return(0); } catch (Exception e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP)); } }
public void OpenMenu() { if (currentLevel == 0) { currentLevel = 1; UnityEngine.UI.LayoutElement el = currentPanelObject.GetComponent <UnityEngine.UI.LayoutElement> (); Rect rect = ((RectTransform)buttonTemplate.transform).rect; float btnHeight = rect.height; el.minHeight = btnHeight * root.MaxHeight; fillCurrentPanel(); } }
static int CalculateLayoutInputVertical(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); UnityEngine.UI.LayoutElement obj = (UnityEngine.UI.LayoutElement)ToLua.CheckObject <UnityEngine.UI.LayoutElement>(L, 1); obj.CalculateLayoutInputVertical(); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static public int set_flexibleHeight(IntPtr l) { try { UnityEngine.UI.LayoutElement self = (UnityEngine.UI.LayoutElement)checkSelf(l); float v; checkType(l, 2, out v); self.flexibleHeight = v; return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int set_flexibleHeight(IntPtr l) { try { UnityEngine.UI.LayoutElement self = (UnityEngine.UI.LayoutElement)checkSelf(l); float v; checkType(l, 2, out v); self.flexibleHeight = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
// Use this for initialization void Start() { screenWidth = Screen.width;// * 1.55f; screenHeight = Screen.height; layoutElement = transform.GetComponent<LayoutElement> (); layoutElement.preferredWidth = screenWidth * (max.x - min.x); layoutElement.preferredHeight = screenHeight * (max.y - min.y); rectTransform = transform.GetComponent<RectTransform> (); rectTransform.offsetMax = new Vector2 (screenWidth - screenWidth * max.x, screenHeight - screenHeight * max.y); rectTransform.offsetMin = new Vector2 (screenWidth * min.x, screenHeight * min.y); }
public virtual void Awake() { containerLayoutElement = container.GetComponent<LayoutElement>(); if (containerLayoutElement == null) containerLayoutElement = container.gameObject.AddComponent<LayoutElement>(); if(foldButton != null) { foldButton.onClick.AddListener(() => { isVisible = !isVisible; containerLayoutElement.gameObject.SetActive(isVisible); }); } }
public RichEditLine(Transform parent, float width) { gameObject = new GameObject("RichEditLine"); transform = gameObject.AddComponent<RectTransform>(); transform.SetParent(parent, false); transform.SetAsLastSibling(); layoutElement = gameObject.AddComponent<LayoutElement>(); layoutElement.preferredWidth = width; layoutElement.preferredHeight = 0; layoutGroup = gameObject.AddComponent<HorizontalLayoutGroup>(); layoutGroup.childForceExpandWidth = false; layoutGroup.childForceExpandHeight = false; layoutGroup.childAlignment = TextAnchor.LowerLeft; }
void Start() { if(!gameObject.GetComponent<LayoutElement>()) { layout = gameObject.AddComponent<LayoutElement>(); } else { layout = gameObject.GetComponent<LayoutElement>(); } layout.flexibleHeight = 1f; layout.flexibleWidth = 1f; Invoke ("Ignore", ignoreTimer); }
IEnumerator GetRefresh() { foreach (var mm in technologyBlocks.transform.GetComponentsInChildren<BlockController>()) { StartCoroutine(RefreshBlock(mm)); } yield return new WaitForSeconds(1f); scrnM.ShowCurrentPanel(); loadingPanel.SetActive(false); vlG = technologyBlocks.transform.GetComponent<VerticalLayoutGroup>(); csF = technologyBlocks.transform.GetComponent<ContentSizeFitter>(); le = technologyBlocks.transform.GetComponentInChildren<LayoutElement>(); vlG.enabled = false; csF.enabled = false; le.enabled = false; }
static int set_preferredWidth(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UnityEngine.UI.LayoutElement obj = (UnityEngine.UI.LayoutElement)o; float arg0 = (float)LuaDLL.luaL_checknumber(L, 2); obj.preferredWidth = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index preferredWidth on a nil value" : e.Message)); } }
static int get_ignoreLayout(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UnityEngine.UI.LayoutElement obj = (UnityEngine.UI.LayoutElement)o; bool ret = obj.ignoreLayout; LuaDLL.lua_pushboolean(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index ignoreLayout on a nil value")); } }
static int set_layoutPriority(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UnityEngine.UI.LayoutElement obj = (UnityEngine.UI.LayoutElement)o; int arg0 = (int)LuaDLL.luaL_checknumber(L, 2); obj.layoutPriority = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index layoutPriority on a nil value")); } }
static int set_ignoreLayout(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UnityEngine.UI.LayoutElement obj = (UnityEngine.UI.LayoutElement)o; bool arg0 = LuaDLL.luaL_checkboolean(L, 2); obj.ignoreLayout = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index ignoreLayout on a nil value")); } }
static int set_flexibleHeight(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UnityEngine.UI.LayoutElement obj = (UnityEngine.UI.LayoutElement)o; float arg0 = (float)LuaDLL.luaL_checknumber(L, 2); obj.flexibleHeight = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index flexibleHeight on a nil value")); } }
static int get_layoutPriority(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UnityEngine.UI.LayoutElement obj = (UnityEngine.UI.LayoutElement)o; int ret = obj.layoutPriority; LuaDLL.lua_pushinteger(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index layoutPriority on a nil value")); } }
static int get_flexibleHeight(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UnityEngine.UI.LayoutElement obj = (UnityEngine.UI.LayoutElement)o; float ret = obj.flexibleHeight; LuaDLL.lua_pushnumber(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index flexibleHeight on a nil value")); } }
void OnDoubleClick() { layout = gameObject.GetComponent<LayoutElement>(); string parseName = name; string[] card = parseName.Split('_'); Card temp = Overlord.localPlayer.wrestler.cards[int.Parse(card[1])]; if (Overlord.localPlayer.turn && !Overlord.localPlayer.countering) { if (temp.atk) { if(!temp.toDown) { placeCard(temp); } else if(temp.toDown && Overlord.opponent.stance > 0) { placeCard(temp); } } } else if (Overlord.localPlayer.countering) { Debug.Log(temp.counter); if(temp.counter) { if (!temp.toDown) { placeCard(temp); } else if (temp.toDown && Overlord.opponent.stance > 0) { placeCard(temp); } } } }
public RichEditBlock(Transform parent, float width, float lineSpacing) { gameObject = new GameObject("RichEditBlock"); transform = gameObject.AddComponent<RectTransform>(); transform.SetParent(parent, false); transform.SetAsLastSibling(); layoutElement = gameObject.AddComponent<LayoutElement>(); layoutElement.preferredWidth = width; layoutElement.preferredHeight = 0; layoutGroup = gameObject.AddComponent<VerticalLayoutGroup>(); layoutGroup.childForceExpandWidth = false; layoutGroup.childForceExpandHeight = false; layoutGroup.childAlignment = TextAnchor.LowerLeft; layoutGroup.spacing = lineSpacing; currentLine = AddNewLine(); }
public void loadAssets() { if (m_rect == null || m_title == null || m_parameters == null || m_viewport == null || m_content == null ) { m_layoutElem = GetComponent<LayoutElement>(); m_rect = (RectTransform)transform; m_title = transform.Find("title_panel").GetComponent<RectTransform>(); m_parameters = transform.Find("parameters").GetComponent<RectTransform>(); m_viewport = m_parameters.Find("viewport").GetComponent<RectTransform>(); m_content = m_viewport.Find("content").GetComponent<RectTransform>(); m_upScroll = transform.Find("scroll_up").GetComponent<RectTransform>(); m_downScroll = transform.Find("scroll_down").GetComponent<RectTransform>(); } }
void Start () { if (myText== null) myText = GetComponent<Text>(); if (layout == null) layout = GetComponent<LayoutElement>(); }
/// <summary> /// Caches and initializes the scroller /// </summary> void Awake() { GameObject go; // cache some components _scrollRect = this.GetComponent<ScrollRect>(); _scrollRectTransform = _scrollRect.GetComponent<RectTransform>(); // destroy any content objects if they exist. Likely there will be // one at design time because Unity gives errors if it can't find one. if (_scrollRect.content != null) { DestroyImmediate(_scrollRect.content.gameObject); } // Create a new active cell view container with a layout group go = new GameObject("Container", typeof(RectTransform)); go.transform.SetParent(_scrollRectTransform, false); if (scrollDirection == ScrollDirectionEnum.Vertical) go.AddComponent<VerticalLayoutGroup>(); else go.AddComponent<HorizontalLayoutGroup>(); _container = go.GetComponent<RectTransform>(); // set the containers anchor and pivot if (scrollDirection == ScrollDirectionEnum.Vertical) { _container.anchorMin = new Vector2(0, 1); _container.anchorMax = Vector2.one; _container.pivot = new Vector2(0.5f, 1f); } else { _container.anchorMin = Vector2.zero; _container.anchorMax = new Vector2(0, 1f); _container.pivot = new Vector2(0, 0.5f); } _container.offsetMax = Vector2.zero; _container.offsetMin = Vector2.zero; _container.localScale = Vector3.one; _scrollRect.content = _container; // cache the scrollbar if it exists if (scrollDirection == ScrollDirectionEnum.Vertical) { _scrollbar = _scrollRect.verticalScrollbar; } else { _scrollbar = _scrollRect.horizontalScrollbar; } // cache the layout group and set up its spacing and padding _layoutGroup = _container.GetComponent<HorizontalOrVerticalLayoutGroup>(); _layoutGroup.spacing = spacing; _layoutGroup.padding = padding; _layoutGroup.childAlignment = TextAnchor.UpperLeft; _layoutGroup.childForceExpandHeight = (scrollDirection == ScrollDirectionEnum.Vertical ? false : true); _layoutGroup.childForceExpandWidth = (scrollDirection == ScrollDirectionEnum.Vertical ? true : false); // force the scroller to scroll in the direction we want _scrollRect.horizontal = scrollDirection == ScrollDirectionEnum.Horizontal; _scrollRect.vertical = scrollDirection == ScrollDirectionEnum.Vertical; // create the padder objects go = new GameObject("First Padder", typeof(RectTransform), typeof(LayoutElement)); go.transform.SetParent(_container, false); _firstPadder = go.GetComponent<LayoutElement>(); go = new GameObject("Last Padder", typeof(RectTransform), typeof(LayoutElement)); go.transform.SetParent(_container, false); _lastPadder = go.GetComponent<LayoutElement>(); // create the recycled cell view container go = new GameObject("Recycled Cells", typeof(RectTransform)); go.transform.SetParent(_scrollRect.transform, false); _recycledCellViewContainer = go.GetComponent<RectTransform>(); _recycledCellViewContainer.gameObject.SetActive(false); // set up the last values for updates _lastScrollRectSize = ScrollRectSize; _lastLoop = loop; _lastScrollbarVisibility = scrollbarVisibility; }
void OnEnable() { layout = GetComponent<LayoutElement>(); }
public override void InitView() { if (isInited) { return; } isInited = true; Transform MainLayout0 = transform.parent.FindChild("MainLayout"); mainLayout = MainLayout0 as RectTransform; Transform MainContainer00 = MainLayout0.FindChild("MainContainer"); mainContainer = MainContainer00 as RectTransform; sideBarLayout = transform as RectTransform; Transform SideBarContainer10 = sideBarLayout.FindChild("SideBarContainer"); sideBarContainer = SideBarContainer10 as RectTransform; Transform SideBarNode100 = SideBarContainer10.FindChild("SideBarNode"); sideBarNode = SideBarNode100 as RectTransform; Transform ButtonLayout101 = SideBarContainer10.FindChild("ButtonLayout"); Transform PanelButtonLocator1010 = ButtonLayout101.FindChild("Locator"); Transform _Button_SideBar10100 = PanelButtonLocator1010.FindChild("SideBarButton"); sideBarButton = _Button_SideBar10100.GetComponent<Button>(); sideBarButton.onClick.AddListener(OnButtonSideBarClicked); var localPosition = sideBarLayout.transform.localPosition; localPosition.x = localPosition.x + SideBarWidth; sideLayoutFixedRightPos = localPosition; sideLayoutFixedLeftPos = sideBarLayout.transform.localPosition; var horizontalLayoutElement = mainLayout.gameObject.GetComponent<HorizontalLayoutGroup>(); if (horizontalLayoutElement == null) { horizontalLayoutElement = mainLayout.gameObject.AddComponent<HorizontalLayoutGroup>(); } horizontalLayoutElement.childForceExpandWidth = false; horizontalLayoutElement.childForceExpandHeight = true; mainContainerLayoutElement = mainContainer.gameObject.GetComponent<LayoutElement>(); if (mainContainerLayoutElement == null) { mainContainerLayoutElement = mainContainer.gameObject.AddComponent<LayoutElement>(); } mainContainerLayoutElement.preferredWidth = mainLayout.rect.width; }
void Awake() { if (textfieldContent) { layoutelementContent = textfieldContent.GetComponent<LayoutElement>(); } }
void Awake() { _layoutElement = GetComponent<LayoutElement>(); _easingControl = GetComponent<EasingControl>(); _easingControl.loopType = EasingControl.LoopType.PingPong; }
private static void CheckLayoutElementNonNull(LayoutElement layoutElement) { if (layoutElement == null) { throw new ArgumentNullException("layoutElement"); } }
void Awake() { text = GetComponent<Text>(); elem = GetComponent<LayoutElement>(); }
void Reset() { _layoutElement = GetComponent<LayoutElement>(); _image = GetComponentInChildren<Image>(); }
/// <summary> /// Call this any time the title text has changed - this will make an attempt to update /// the contract window title. We do this because otherwise the window will only ever read /// the title once. /// </summary> /// <param name="newTitle">New title to display</param> public void UpdateContractWindow(string newTitle) { // Get the cascading list for our contract if (text == null && ContractsApp.Instance != null) { UICascadingList.CascadingListItem list = TitleTrackerHelper.uiListMap.ContainsKey(parameter.Root.ContractGuid) ? TitleTrackerHelper.uiListMap[parameter.Root.ContractGuid] : null; if (list != null) { foreach (KSP.UI.UIListItem item in list.items) { TMPro.TextMeshProUGUI textComponent = item.GetComponentsInChildren<TMPro.TextMeshProUGUI>(true).FirstOrDefault(); if (textComponent != null) { // Check for any string in titleTracker foreach (string title in titles) { if (textComponent.text.EndsWith(">" + title + "</color>")) { text = textComponent; layoutElement = item.GetComponentsInChildren<LayoutElement>(true).FirstOrDefault(); break; } } if (text != null) { break; } } } } } if (text) { // Clear the titleTracker, and replace the text if (!text.text.Contains(">" + newTitle + "<")) { float preHeight = text.preferredHeight; titles.Clear(); text.text = text.text.Substring(0, text.text.IndexOf(">") + 1) + newTitle + "</color>"; titles.Add(newTitle); float postHeight = text.preferredHeight; if (preHeight != postHeight) { text.rectTransform.sizeDelta = new Vector2(text.rectTransform.sizeDelta.x, postHeight + 4f); layoutElement.preferredHeight = postHeight + 6f; // Force an update to the layout even when not active if (!layoutElement.IsActive()) { LayoutRebuilder.MarkLayoutForRebuild(layoutElement.transform as RectTransform); } } } } // Contracts Window + update ContractsWindow.SetParameterTitle(parameter, newTitle); }
void ResetChildrenWidth(LayoutElement element, int index) { element.preferredWidth = widths[index]; }
private void Awake() { rt = GetComponent<RectTransform>(); layout = GetComponent<LayoutElement>(); }
private void Start() { layout = GetComponent<LayoutElement>(); }
/*private bool horizontalLast; private bool verticalLast; private bool asDropdown = false; private float maxHeight; protected override void Start() { base.Start(); this.horizontalLast = this.horizontal; this.verticalLast = this.vertical; this.UpdateScrollBars(); } protected override void LateUpdate() { base.LateUpdate(); if (this.horizontalLast != this.horizontal || this.verticalLast != this.vertical) { this.UpdateScrollBars(); } } protected void UpdateScrollBars() { if (this.horizontalScrollbar != null) this.horizontalScrollbar.interactable = this.horizontal; if (this.verticalScrollbar != null) this.verticalScrollbar.interactable = this.vertical; this.horizontalLast = this.horizontal; this.verticalLast = this.vertical; } protected override void OnRectTransformDimensionsChange() { base.OnRectTransformDimensionsChange(); this.UpdateDropdown(); } protected override void OnTransformParentChanged() { base.OnTransformParentChanged(); this.UpdateDropdown(); } public void UpdateDropdown() { if (this.asDropdown == false) return; if (this.IsActive() == false) return; if (this.layoutElement != null) { var rect = this.transform as RectTransform; if (rect.sizeDelta.y >= this.maxHeight) { this.vertical = true; this.layoutElement.minHeight = maxHeight; this.layoutElement.preferredHeight = -1f; } else { this.vertical = false; this.layoutElement.minHeight = -1f; this.layoutElement.preferredHeight = maxHeight; } this.UpdateScrollBars(); } } public void SetupAsDropdown(float maxHeight) { this.asDropdown = true; this.maxHeight = maxHeight; this.UpdateDropdown(); }*/ #if UNITY_EDITOR protected override void OnValidate() { base.OnValidate(); this.layoutElement = this.GetComponent<LayoutElement>(); }
void Start() { rectTransform = GetComponent<RectTransform>(); layoutGroup = GetComponentInParent<LayoutGroup>(); layoutElement = GetComponent<LayoutElement>(); gameMaster.simpleOnGameStateChanges += UpdateInteractivity; GetDirectionAsEnum(); UpdateDisplay(); startParent = transform.parent; UpdateInteractivity(); }
// Use this for initialization void Awake() { aspectRatio = GetComponent<AspectRatioFitter>(); canvasGroup = GetComponent<CanvasGroup>(); Assert.IsTrue(canvasGroup.alpha == 0); layout = GetComponent<LayoutElement>(); background = GetComponent<Image>(); myMat = CharacterSprite.material = Instantiate(CharacterSprite.material); if (GameSelection.colorBounds) { visualsSelectSensitivity = 0; } }