// Use this for initialization void Start () { _vLayout = this.GetComponent<VerticalLayoutGroup>(); _rt = (RectTransform)player_slot.transform; _old_top = _vLayout.padding.top; _old_spacing = _rt.rect.height; _vLayout.spacing = spacing_factor * _old_spacing; _screen_height = Screen.height; }
public void Start() { _instance = this; _layout = playerListContentTransform.GetComponent<VerticalLayoutGroup>(); // Evita que se destruya el objeto del menu que contiene la lista de jugadores // derivados de la clase NetworkLobbyPlayer DontDestroyOnLoad(gameObject); }
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; }
public override void gaxb_init() { gameObject = new GameObject ("<PUVerticalLayoutGroup/>", typeof(RectTransform)); layout = gameObject.AddComponent<VerticalLayoutGroup> (); if (spacing != null) { layout.spacing = (float)spacing; } if (padding != null) { layout.padding = new RectOffset((int)padding.Value.x, (int)padding.Value.y, (int)padding.Value.z, (int)padding.Value.w); } if(childAlignment != null) { if (childAlignment == PlanetUnity2.GridLayoutChildAlignment.upperLeft) layout.childAlignment = TextAnchor.UpperLeft; if (childAlignment == PlanetUnity2.GridLayoutChildAlignment.upperCenter) layout.childAlignment = TextAnchor.UpperCenter; if (childAlignment == PlanetUnity2.GridLayoutChildAlignment.upperRight) layout.childAlignment = TextAnchor.UpperRight; if (childAlignment == PlanetUnity2.GridLayoutChildAlignment.middleLeft) layout.childAlignment = TextAnchor.MiddleLeft; if (childAlignment == PlanetUnity2.GridLayoutChildAlignment.middleCenter) layout.childAlignment = TextAnchor.MiddleCenter; if (childAlignment == PlanetUnity2.GridLayoutChildAlignment.middleRight) layout.childAlignment = TextAnchor.MiddleRight; if (childAlignment == PlanetUnity2.GridLayoutChildAlignment.lowerLeft) layout.childAlignment = TextAnchor.LowerLeft; if (childAlignment == PlanetUnity2.GridLayoutChildAlignment.lowerCenter) layout.childAlignment = TextAnchor.LowerCenter; if (childAlignment == PlanetUnity2.GridLayoutChildAlignment.lowerRight) layout.childAlignment = TextAnchor.LowerRight; } }
public void OnEnable() { _instance = this; _layout = playerListContentTransform.GetComponent <VerticalLayoutGroup>(); }
public override void Init(ParameterMetadata parameterMetadata, string type, object value, VerticalLayoutGroup layoutGroupToBeDisabled, GameObject canvasRoot, OnChangeParameterHandlerDelegate onChangeParameterHandler, bool linkable = true) { Parameter = DropdownParameter; base.Init(parameterMetadata, type, value, layoutGroupToBeDisabled, canvasRoot, onChangeParameterHandler, linkable); SetOnValueChanged(onChangeParameterHandler); SetValue(value); }
private void createResultItems() { foreach (CommandPuzzle commandPuzzle in listCommands) { GameObject panel = new GameObject("Panel"); panel.AddComponent <CanvasRenderer>(); RectTransform panelRectTransform = panel.AddComponent <RectTransform>(); panelRectTransform.sizeDelta = new Vector2(520f, 100f); Image panelImageBackground = panel.AddComponent <Image>(); panelImageBackground.sprite = (Sprite)Resources.Load("Images/BoardResult", typeof(Sprite)); VerticalLayoutGroup panelVerticalLayoutGroup = panel.AddComponent <VerticalLayoutGroup>(); panelVerticalLayoutGroup.padding.top = 30; panelVerticalLayoutGroup.padding.bottom = 30; panelVerticalLayoutGroup.padding.left = 30; panelVerticalLayoutGroup.padding.right = 30; ContentSizeFitter panelContentSizeFitter = panel.AddComponent <ContentSizeFitter>(); panelContentSizeFitter.verticalFit = ContentSizeFitter.FitMode.MinSize; GameObject textTitle = new GameObject("TextMeshProUGUI"); textTitle.AddComponent <CanvasRenderer>(); textTitle.AddComponent <RectTransform>(); VerticalLayoutGroup textTitleVerticalLayoutGroup = textTitle.AddComponent <VerticalLayoutGroup>(); textTitleVerticalLayoutGroup.padding.top = 10; textTitleVerticalLayoutGroup.padding.bottom = 60; textTitleVerticalLayoutGroup.padding.left = 10; textTitleVerticalLayoutGroup.padding.right = 10; ContentSizeFitter textTitleContentSizeFitter = textTitle.AddComponent <ContentSizeFitter>(); textTitleContentSizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; TextMeshProUGUI textTitleMeshPro = textTitle.AddComponent <TextMeshProUGUI>(); textTitleMeshPro.text = commandPuzzle.commandTypeName; textTitleMeshPro.fontStyle = FontStyles.Bold; textTitleMeshPro.color = Color.red; textTitleMeshPro.fontSize = 40; textTitle.transform.SetParent(panel.transform, false); if (commandPuzzle.commandType == "if") { // Title GameObject titleConditionText = new GameObject("TextMeshProUGUI"); titleConditionText.AddComponent <CanvasRenderer>(); titleConditionText.AddComponent <RectTransform>(); VerticalLayoutGroup titleConditionTextVerticalLayoutGroup = titleConditionText.AddComponent <VerticalLayoutGroup>(); titleConditionTextVerticalLayoutGroup.padding.top = 10; titleConditionTextVerticalLayoutGroup.padding.bottom = 20; titleConditionTextVerticalLayoutGroup.padding.left = 10; titleConditionTextVerticalLayoutGroup.padding.right = 10; ContentSizeFitter titleConditionTextContentSizeFitter = titleConditionText.AddComponent <ContentSizeFitter>(); titleConditionTextContentSizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; TextMeshProUGUI titleConditionTextMeshPro = titleConditionText.AddComponent <TextMeshProUGUI>(); titleConditionTextMeshPro.text = "Quando"; titleConditionTextMeshPro.fontSize = 24; titleConditionTextMeshPro.color = new Color32(255, 147, 0, 255); titleConditionText.transform.SetParent(panel.transform, false); // Condition GameObject conditionText = new GameObject("TextMeshProUGUI"); conditionText.AddComponent <CanvasRenderer>(); conditionText.AddComponent <RectTransform>(); VerticalLayoutGroup conditionTextVerticalLayoutGroup = conditionText.AddComponent <VerticalLayoutGroup>(); conditionTextVerticalLayoutGroup.padding.top = 10; conditionTextVerticalLayoutGroup.padding.bottom = 40; conditionTextVerticalLayoutGroup.padding.left = 60; conditionTextVerticalLayoutGroup.padding.right = 10; ContentSizeFitter conditionTextContentSizeFitter = conditionText.AddComponent <ContentSizeFitter>(); conditionTextContentSizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; TextMeshProUGUI conditionTextMeshPro = conditionText.AddComponent <TextMeshProUGUI>(); conditionTextMeshPro.text = commandPuzzle.commandConditionName; conditionTextMeshPro.fontSize = 25; conditionText.transform.SetParent(panel.transform, false); // Title GameObject actionTitleText = new GameObject("TextMeshProUGUI"); actionTitleText.AddComponent <CanvasRenderer>(); actionTitleText.AddComponent <RectTransform>(); VerticalLayoutGroup actionTitleTextVerticalLayoutGroup = actionTitleText.AddComponent <VerticalLayoutGroup>(); actionTitleTextVerticalLayoutGroup.padding.top = 10; actionTitleTextVerticalLayoutGroup.padding.bottom = 20; actionTitleTextVerticalLayoutGroup.padding.left = 10; actionTitleTextVerticalLayoutGroup.padding.right = 10; ContentSizeFitter actionTitleTextContentSizeFitter = actionTitleText.AddComponent <ContentSizeFitter>(); actionTitleTextContentSizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; TextMeshProUGUI actionTitleTextMeshPro = actionTitleText.AddComponent <TextMeshProUGUI>(); actionTitleTextMeshPro.text = "Faça"; actionTitleTextMeshPro.fontSize = 24; actionTitleTextMeshPro.color = new Color32(91, 255, 83, 255); actionTitleText.transform.SetParent(panel.transform, false); // Command GameObject commandText = new GameObject("TextMeshProUGUI"); commandText.AddComponent <CanvasRenderer>(); commandText.AddComponent <RectTransform>(); VerticalLayoutGroup commandTextVerticalLayoutGroup = commandText.AddComponent <VerticalLayoutGroup>(); commandTextVerticalLayoutGroup.padding.top = 10; commandTextVerticalLayoutGroup.padding.bottom = 20; commandTextVerticalLayoutGroup.padding.left = 20; commandTextVerticalLayoutGroup.padding.right = 10; ContentSizeFitter commandTextContentSizeFitter = commandText.AddComponent <ContentSizeFitter>(); commandTextContentSizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; TextMeshProUGUI commandTextMeshPro = commandText.AddComponent <TextMeshProUGUI>(); commandTextMeshPro.text = commandPuzzle.commandName; commandTextMeshPro.fontSize = 25; commandText.transform.SetParent(panel.transform, false); } else if (commandPuzzle.commandType == "for") { GameObject textSubTitle = new GameObject("TextMeshProUGUI"); textSubTitle.AddComponent <CanvasRenderer>(); textSubTitle.AddComponent <RectTransform>(); VerticalLayoutGroup textSubTitleVerticalLayoutGroup = textSubTitle.AddComponent <VerticalLayoutGroup>(); textSubTitleVerticalLayoutGroup.padding.top = 0; textSubTitleVerticalLayoutGroup.padding.bottom = 40; textSubTitleVerticalLayoutGroup.padding.left = 10; textSubTitleVerticalLayoutGroup.padding.right = 10; ContentSizeFitter textSubTitleContentSizeFitter = textSubTitle.AddComponent <ContentSizeFitter>(); textSubTitleContentSizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; TextMeshProUGUI textCounterMeshPro = textSubTitle.AddComponent <TextMeshProUGUI>(); textCounterMeshPro.text = "Contador: " + commandPuzzle.countLoop; textCounterMeshPro.fontStyle = FontStyles.Bold; textCounterMeshPro.color = Color.red; textCounterMeshPro.fontSize = 30; textCounterMeshPro.transform.SetParent(panel.transform, false); foreach (CommandFor commandFor in commandPuzzle.commandsFor) { GameObject commandText = new GameObject("TextMeshProUGUI"); commandText.AddComponent <CanvasRenderer>(); commandText.AddComponent <RectTransform>(); VerticalLayoutGroup commandTextVerticalLayoutGroup = commandText.AddComponent <VerticalLayoutGroup>(); commandTextVerticalLayoutGroup.padding.top = 10; commandTextVerticalLayoutGroup.padding.bottom = 20; commandTextVerticalLayoutGroup.padding.left = 10; commandTextVerticalLayoutGroup.padding.right = 10; ContentSizeFitter commandTextContentSizeFitter = commandText.AddComponent <ContentSizeFitter>(); commandTextContentSizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; TextMeshProUGUI commandTexteMeshPro = commandText.AddComponent <TextMeshProUGUI>(); commandTexteMeshPro.text = commandFor.commandName; commandTexteMeshPro.fontSize = 25; commandText.transform.SetParent(panel.transform, false); } } panel.transform.SetParent(panelGameObject.transform, false); commandPuzzle.panelResult = panel; generatedPanelsObjects.Add(panel); } }
private void SetupVerticalLayoutComponent() { verticalLayoutComponent = GetComponent <VerticalLayoutGroup>(); verticalLayoutComponent.childForceExpandHeight = true; verticalLayoutComponent.childForceExpandWidth = true; }
public void Apply(VerticalLayoutGroup e) { e.padding = padding; e.spacing = spacing; }
protected override void AddComponents() { // Add the gameObjects var viewportGO = InstanciateObject("Viewport", gameObject); var containerGO = InstanciateObject("Container", viewportGO); var vScrollbarGO = InstanciateScrollbar("Vertical Scrollbar", gameObject, out vScrollbarCmp, out vScrollbarImageCmp, out vScrollbarHandleImageCmp); var hScrollbarGO = InstanciateScrollbar("Horizontal Scrollbar", gameObject, out hScrollbarCmp, out hScrollbarImageCmp, out hScrollbarHandleImageCmp); // Set virtual parent virtualChildContainer = containerGO; // Add Components scrollRectCmp = propsScrollRect().Set(gameObject); rectMask2Cmp = propsRectMask2D().Set(viewportGO); verticalLayoutCmp = propsVerticalLayoutGroup().Set(containerGO); contentSizeCmp = propsContentSizeFilter().Set(containerGO); propsVScrollbarImage().SetAllExceptType(vScrollbarImageCmp); propsVScrollbar().Set(vScrollbarCmp); propsVScrollbarHandleImageCmp().SetAllExceptType(vScrollbarHandleImageCmp); propsHScrollbarImage().SetAllExceptType(hScrollbarImageCmp); propsHScrollbar().Set(hScrollbarCmp); propsHScrollbarHandleImageCmp().SetAllExceptType(hScrollbarHandleImageCmp); // Relations scrollRectCmp.content = containerGO.GetComponent <RectTransform>(); scrollRectCmp.viewport = viewportGO.GetComponent <RectTransform>(); scrollRectCmp.horizontalScrollbar = hScrollbarCmp; scrollRectCmp.verticalScrollbar = vScrollbarCmp; // Obtain percentage size SetReferenceSize(new RectTransformSetter()); new RectTransformBSetter() { pivot = new Vector2(0f, 1f), localPosition = new Vector2(0f, 0f), anchorMin = new Vector2(0f, 0f), anchorMax = new Vector2(1, 1f), sizeDelta = new Vector2(0, 0), }.SetOrSearchBySizeDelta(viewportGO); new RectTransformBSetter() { pivot = new Vector2(0f, 1f), localPosition = new Vector2(0, 0f), anchorMin = new Vector2(0, 0f), anchorMax = new Vector2(1, 1f), offsetMin = new Vector2(0, 0f), offsetMax = new Vector2(0, 0f), }.SetOrSearchByAnchors(containerGO); new RectTransformBSetter() { pivot = new Vector2(1f, 1f), localPosition = new Vector2(0f, 0), anchorMin = new Vector2(1, 0f), anchorMax = new Vector2(1, 1f), sizeDelta = new Vector2(20, 0f), // 20,0 }.SetOrSearchBySizeDelta(vScrollbarGO); new RectTransformBSetter() { pivot = new Vector2(0f, 0f), localPosition = new Vector2(0f, 0), anchorMin = new Vector2(0f, 0f), anchorMax = new Vector2(1f, 0f), sizeDelta = new Vector2(-20, 20f), // -20,20 }.SetOrSearchBySizeDelta(hScrollbarGO); }
public KsmGuiVerticalScrollView(KsmGuiBase parent, int contentSpacing = 5, int contentPaddingLeft = 5, int contentPaddingRight = 5, int contentPaddingTop = 5, int contentPaddingBottom = 5) : base(parent) { ScrollRect scrollRect = TopObject.AddComponent <ScrollRect>(); scrollRect.horizontal = false; scrollRect.vertical = true; scrollRect.movementType = ScrollRect.MovementType.Elastic; scrollRect.elasticity = 0.1f; scrollRect.inertia = true; scrollRect.decelerationRate = 0.15f; scrollRect.scrollSensitivity = 10f; scrollRect.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport; scrollRect.verticalScrollbarSpacing = -3f; Image scrollRectBackground = TopObject.AddComponent <Image>(); scrollRectBackground.color = KsmGuiStyle.boxColor; // viewport object (child of top object) GameObject viewport = new GameObject("viewport"); RectTransform viewportTransform = viewport.AddComponent <RectTransform>(); viewport.AddComponent <CanvasRenderer>(); // Note : using a standard "Mask" has a bug where scrollrect content is visible // in other windows scollrects (like if all masks were "global" for all masked content) // see https://issuetracker.unity3d.com/issues/scroll-view-content-is-visible-outside-of-mask-when-there-is-another-masked-ui-element-in-the-same-canvas // using a RectMask2D fixes it, at the cost of the ability to use an image mask (but we don't care) viewport.AddComponent <RectMask2D>(); //Mask viewportMask = viewport.AddComponent<Mask>(); //viewportMask.showMaskGraphic = false; //Image viewportImage = viewport.AddComponent<Image>(); //viewportImage.color = new Color(1f, 1f, 1f, 1f); viewportTransform.SetParentFixScale(TopTransform); scrollRect.viewport = viewportTransform; // content object (child of viewport) GameObject contentObject = new GameObject("content"); Content = contentObject.AddComponent <RectTransform>(); Content.anchorMin = new Vector2(0f, 1f); Content.anchorMax = new Vector2(1f, 1f); Content.pivot = new Vector2(0f, 1f); Content.anchoredPosition = new Vector2(0f, 0f); Content.sizeDelta = new Vector2(0f, 0f); ContentSizeFitter sizeFitter = contentObject.AddComponent <ContentSizeFitter>(); sizeFitter.horizontalFit = ContentSizeFitter.FitMode.Unconstrained; sizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; ContentGroup = contentObject.AddComponent <VerticalLayoutGroup>(); ContentGroup.padding = new RectOffset(contentPaddingLeft, contentPaddingRight, contentPaddingTop, contentPaddingBottom); ContentGroup.spacing = contentSpacing; ContentGroup.childAlignment = TextAnchor.UpperLeft; ContentGroup.childControlHeight = true; ContentGroup.childControlWidth = true; ContentGroup.childForceExpandHeight = false; ContentGroup.childForceExpandWidth = false; Content.SetParentFixScale(viewportTransform); scrollRect.content = Content; // scrollbar (child of top object) GameObject scrollbar = new GameObject("scrollbar"); RectTransform scrollbarTransform = scrollbar.AddComponent <RectTransform>(); scrollbarTransform.anchorMin = new Vector2(1f, 0f); scrollbarTransform.anchorMax = new Vector2(1f, 1f); scrollbarTransform.pivot = new Vector2(1f, 1f); scrollbarTransform.anchoredPosition = new Vector2(0f, 0f); scrollbarTransform.sizeDelta = new Vector2(10f, 0f); // scrollbar width scrollbar.AddComponent <CanvasRenderer>(); Image scrollBarImage = scrollbar.AddComponent <Image>(); scrollBarImage.color = Color.black; Scrollbar scrollbarComponent = scrollbar.AddComponent <Scrollbar>(); scrollbarComponent.interactable = true; scrollbarComponent.transition = Selectable.Transition.ColorTint; scrollbarComponent.colors = new ColorBlock() { normalColor = Color.white, highlightedColor = Color.white, pressedColor = new Color(0.8f, 0.8f, 0.8f), disabledColor = new Color(0.8f, 0.8f, 0.8f, 0.5f), colorMultiplier = 1f, fadeDuration = 0.1f }; scrollbarComponent.navigation = new Navigation() { mode = Navigation.Mode.None }; scrollbarComponent.direction = Scrollbar.Direction.BottomToTop; scrollRect.verticalScrollbar = scrollbarComponent; scrollbarTransform.SetParentFixScale(TopTransform); // scrollbar sliding area GameObject slidingArea = new GameObject("slidingArea"); RectTransform slidingAreaTransform = slidingArea.AddComponent <RectTransform>(); slidingAreaTransform.anchorMin = new Vector2(0f, 0f); slidingAreaTransform.anchorMax = new Vector2(1f, 1f); slidingAreaTransform.pivot = new Vector2(0.5f, 0.5f); slidingAreaTransform.anchoredPosition = new Vector2(5f, 5f); slidingAreaTransform.sizeDelta = new Vector2(5f, 5f); // scrollbar width / 2 slidingAreaTransform.SetParentFixScale(scrollbarTransform); // scrollbar handle GameObject scrollbarHandle = new GameObject("scrollbarHandle"); RectTransform handleTransform = scrollbarHandle.AddComponent <RectTransform>(); scrollbarHandle.AddComponent <CanvasRenderer>(); handleTransform.anchorMin = new Vector2(0f, 0f); handleTransform.anchorMax = new Vector2(1f, 1f); handleTransform.pivot = new Vector2(0.5f, 0.5f); handleTransform.anchoredPosition = new Vector2(-4f, -4f); // relative to sliding area width handleTransform.sizeDelta = new Vector2(-4f, -4f); // relative to sliding area width scrollbarComponent.handleRect = handleTransform; Image handleImage = scrollbarHandle.AddComponent <Image>(); handleImage.color = new Color(0.4f, 0.4f, 0.4f); handleTransform.SetParentFixScale(slidingAreaTransform); scrollbarComponent.targetGraphic = handleImage; }
public void HideTaskParts() { Destroy(partsList.gameObject); partsList = null; arrowTransform.Rotate(0, 0, 90); }
protected override void Awake() { base.Awake(); if (m_virtualContent == null) { return; } m_virtualContentTransformChangeListener = m_virtualContent.GetComponent <RectTransformChangeListener>(); m_virtualContentTransformChangeListener.RectTransformChanged += OnVirtualContentTransformChaged; UpdateVirtualContentPosition(); if (m_useGrid) { LayoutGroup layoutGroup = m_virtualContent.GetComponent <LayoutGroup>(); if (layoutGroup != null && !(layoutGroup is GridLayoutGroup)) { DestroyImmediate(layoutGroup); } GridLayoutGroup gridLayout = m_virtualContent.GetComponent <GridLayoutGroup>(); if (gridLayout == null) { gridLayout = m_virtualContent.gameObject.AddComponent <GridLayoutGroup>(); } gridLayout.cellSize = ContainerPrefab.rect.size; gridLayout.childAlignment = TextAnchor.UpperLeft; gridLayout.startCorner = GridLayoutGroup.Corner.UpperLeft; gridLayout.spacing = m_gridSpacing; if (m_mode == VirtualizingMode.Vertical) { gridLayout.startAxis = GridLayoutGroup.Axis.Horizontal; gridLayout.constraint = GridLayoutGroup.Constraint.FixedColumnCount; } else { gridLayout.startAxis = GridLayoutGroup.Axis.Vertical; gridLayout.constraint = GridLayoutGroup.Constraint.FixedRowCount; } m_gridLayoutGroup = gridLayout; } else { if (m_mode == VirtualizingMode.Horizontal) { //In horizontal mode we destroy VerticalLayoutGroup or GridLayoutGroup if exists LayoutGroup layoutGroup = m_virtualContent.GetComponent <LayoutGroup>(); if (layoutGroup != null && !(layoutGroup is HorizontalLayoutGroup)) { DestroyImmediate(layoutGroup); } // Create HorizontalLayoutGroup if does not exists HorizontalLayoutGroup horizontalLayout = m_virtualContent.GetComponent <HorizontalLayoutGroup>(); if (horizontalLayout == null) { horizontalLayout = m_virtualContent.gameObject.AddComponent <HorizontalLayoutGroup>(); } // Setup HorizontalLayoutGroup behavior to arrange ui containers correctly horizontalLayout.childControlHeight = true; horizontalLayout.childControlWidth = false; horizontalLayout.childForceExpandWidth = false; } else { //In horizontal mode we destroy HorizontalLayoutGroup or GridLayoutGroup if exists LayoutGroup layoutGroup = m_virtualContent.GetComponent <LayoutGroup>(); if (layoutGroup != null && !(layoutGroup is VerticalLayoutGroup)) { DestroyImmediate(layoutGroup); } // Create VerticalLayoutGroup if does not exists VerticalLayoutGroup verticalLayout = m_virtualContent.GetComponent <VerticalLayoutGroup>(); if (verticalLayout == null) { verticalLayout = m_virtualContent.gameObject.AddComponent <VerticalLayoutGroup>(); } // Setup VerticalLayoutGroup behavior to arrange ui containers correctly verticalLayout.childControlWidth = true; verticalLayout.childControlHeight = false; verticalLayout.childForceExpandHeight = false; } } // Set ScrollSensitivity to be exactly the same as ContainerSize scrollSensitivity = ContainerSize;// * ContainersPerGroup; }
private static void CreateInContextMenu() { GameObject dataGridView = new GameObject("DataGridView"); if (Selection.activeTransform == null) { GameObject canvas = new GameObject("Canvas"); canvas.AddComponent <Canvas>(); canvas.AddComponent <CanvasScaler>(); canvas.AddComponent <GraphicRaycaster>(); dataGridView.transform.parent = canvas.transform; } else { dataGridView.transform.parent = Selection.activeTransform; } dataGridView.AddComponent <DataGridViewRowSelector>(); Image image = dataGridView.AddComponent <Image>(); image.enabled = false; Color color = Color.white; color.a = 0.7f; image.color = color; RectTransform dgvRt = dataGridView.GetComponent <RectTransform>(); dgvRt.anchorMin = Vector2.zero; dgvRt.anchorMax = Vector2.one; dgvRt.offsetMin = Vector2.zero; dgvRt.offsetMax = Vector3.zero; dgvRt.localScale = Vector3.one; dgvRt.anchoredPosition3D = Vector3.zero; GameObject header = new GameObject("Columns"); Image headerImage = header.AddComponent <Image>(); headerImage.color = new Color(0.7f, 0.7f, 0.7f); RectTransform headerRT = header.GetComponent <RectTransform>(); headerRT.SetParent(dgvRt); headerRT.localScale = Vector3.one; headerRT.anchorMin = new Vector2(0, 1); headerRT.anchorMax = Vector2.one; headerRT.pivot = new Vector2(0.5f, 1); headerRT.anchoredPosition3D = Vector3.zero; headerRT.offsetMin = new Vector2(0f, -50f); headerRT.offsetMax = Vector2.zero; HorizontalLayoutGroup headerHLG = header.AddComponent <HorizontalLayoutGroup>(); headerHLG.childAlignment = TextAnchor.MiddleLeft; headerHLG.childForceExpandWidth = false; headerHLG.childControlHeight = true; headerHLG.spacing = 1; GameObject scrollObject = new GameObject("Scrollbar Vertical"); Image scrollImage = scrollObject.AddComponent <Image>(); scrollImage.color = new Color32(229, 229, 229, 255); RectTransform scrollRT = scrollObject.GetComponent <RectTransform>(); Scrollbar scrollbar = scrollObject.AddComponent <Scrollbar>(); scrollbar.direction = Scrollbar.Direction.BottomToTop; GameObject slidingArea = new GameObject("Sliding Area"); RectTransform slidingAreaRT = slidingArea.AddComponent <RectTransform>(); slidingAreaRT.SetParent(scrollRT); slidingAreaRT.localScale = Vector3.one; slidingAreaRT.anchorMin = Vector2.zero; slidingAreaRT.anchorMax = Vector2.one; slidingAreaRT.anchoredPosition3D = Vector3.zero; slidingAreaRT.offsetMin = new Vector2(10, 0); slidingAreaRT.offsetMax = new Vector2(-10, 0); GameObject handleObject = new GameObject("Handle"); Image handleImage = handleObject.AddComponent <Image>(); handleImage.color = new Color32(180, 180, 180, 255); RectTransform handleRT = handleObject.GetComponent <RectTransform>(); scrollbar.handleRect = handleRT; handleRT.SetParent(slidingAreaRT); handleRT.localScale = Vector3.one; handleRT.anchorMin = new Vector2(0, 1); handleRT.anchorMax = Vector2.one; handleRT.anchoredPosition3D = new Vector3(5, 0, 0); handleRT.offsetMin = new Vector2(-10, 0); handleRT.offsetMax = new Vector2(10, 0); GameObject rows = new GameObject("Rows"); rows.AddComponent <Mask>(); rows.AddComponent <Image>(); RectTransform rowsRt = rows.GetComponent <RectTransform>(); rowsRt.SetParent(dgvRt); rowsRt.localScale = Vector3.one; rowsRt.anchorMin = Vector2.zero; rowsRt.anchorMax = Vector2.one; rowsRt.pivot = new Vector2(0.5f, 1); rowsRt.anchoredPosition3D = Vector3.zero; rowsRt.offsetMin = Vector2.zero; rowsRt.offsetMax = new Vector2(0f, -50f); ScrollRect scrollRect = rows.AddComponent <ScrollRect>(); scrollRect.verticalScrollbar = scrollbar; scrollRect.scrollSensitivity = 20; scrollRect.horizontal = false; scrollRect.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport; scrollRect.verticalScrollbarSpacing = -20; scrollRT.SetParent(rowsRt); scrollRT.localScale = Vector3.one; scrollRT.anchorMin = new Vector2(1, 0); scrollRT.anchorMax = Vector2.one; scrollRT.pivot = Vector2.one; scrollRT.anchoredPosition3D = Vector3.zero; scrollRT.offsetMax = Vector2.zero; scrollRT.offsetMin = new Vector2(-20, -17); GameObject viewport = new GameObject("Viewport"); Image viewportImage = viewport.AddComponent <Image>(); RectTransform viewportRT = viewport.GetComponent <RectTransform>(); viewportRT.SetParent(rowsRt); scrollRect.viewport = viewportRT; viewportRT.localScale = Vector3.one; viewportRT.anchorMin = Vector2.zero; viewportRT.anchorMax = Vector2.one; viewportRT.anchoredPosition3D = Vector3.zero; viewportRT.offsetMin = Vector2.zero; viewportRT.offsetMax = Vector2.zero; viewport.AddComponent <Mask>(); GameObject content = new GameObject("Content"); content.transform.parent = viewport.transform; RectTransform contentRT = content.AddComponent <RectTransform>(); scrollRect.content = contentRT; contentRT.pivot = new Vector2(0.5f, 1); contentRT.localScale = Vector3.one; contentRT.anchorMin = new Vector2(0f, 1f); contentRT.anchorMax = Vector2.one; contentRT.anchoredPosition3D = Vector3.zero; contentRT.offsetMin = Vector2.zero; contentRT.offsetMax = Vector2.zero; VerticalLayoutGroup vlg = content.AddComponent <VerticalLayoutGroup>(); vlg.spacing = 1; vlg.childForceExpandWidth = true; vlg.childForceExpandHeight = false; vlg.childControlWidth = true; ContentSizeFitter csf = content.AddComponent <ContentSizeFitter>(); csf.verticalFit = ContentSizeFitter.FitMode.PreferredSize; scrollRT.SetSiblingIndex(1); DataGridView dgv = dataGridView.GetComponent <DataGridView>(); dgv.rows.changed.AddListener(dgv.OnChange); dgv.columnsComponent = header; dgv.rowsComponent = content; }
protected void Init() { backgroundlayout = background.GetComponent <VerticalLayoutGroup>(); backgroundSize = background.GetComponent <ContentSizeFitter>(); textSize = text.GetComponentInChildren <ContentSizeFitter>(); }
protected override void Awake() { base.Awake(); m_VerticalLayoutGroup = GetComponent <VerticalLayoutGroup>(); }
public override GameObject CreateObject(Transform parent) { TextPageScrollView textScrollView = Object.Instantiate(ScrollViewTemplate, parent); textScrollView.name = "BSMLScrollView"; Button pageUpButton = textScrollView.GetField <Button, ScrollView>("_pageUpButton"); Button pageDownButton = textScrollView.GetField <Button, ScrollView>("_pageDownButton"); VerticalScrollIndicator verticalScrollIndicator = textScrollView.GetField <VerticalScrollIndicator, ScrollView>("_verticalScrollIndicator"); RectTransform viewport = textScrollView.GetField <RectTransform, ScrollView>("_viewport"); viewport.gameObject.AddComponent <VRGraphicRaycaster>().SetField("_physicsRaycaster", BeatSaberUI.PhysicsRaycasterWithCache); Object.Destroy(textScrollView.GetField <TextMeshProUGUI, TextPageScrollView>("_text").gameObject); GameObject gameObject = textScrollView.gameObject; Object.Destroy(textScrollView); gameObject.SetActive(false); BSMLScrollView scrollView = gameObject.AddComponent <BSMLScrollView>(); scrollView.SetField <ScrollView, Button>("_pageUpButton", pageUpButton); scrollView.SetField <ScrollView, Button>("_pageDownButton", pageDownButton); scrollView.SetField <ScrollView, VerticalScrollIndicator>("_verticalScrollIndicator", verticalScrollIndicator); scrollView.SetField <ScrollView, RectTransform>("_viewport", viewport); (scrollView as ScrollView).SetField("_platformHelper", BeatSaberUI.PlatformHelper); viewport.anchorMin = new Vector2(0, 0); viewport.anchorMax = new Vector2(1, 1); GameObject parentObj = new GameObject(); parentObj.name = "BSMLScrollViewContent"; parentObj.transform.SetParent(viewport, false); ContentSizeFitter contentSizeFitter = parentObj.AddComponent <ContentSizeFitter>(); contentSizeFitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; contentSizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; VerticalLayoutGroup verticalLayout = parentObj.AddComponent <VerticalLayoutGroup>(); verticalLayout.childForceExpandHeight = false; verticalLayout.childForceExpandWidth = false; verticalLayout.childControlHeight = true; verticalLayout.childControlWidth = true; verticalLayout.childAlignment = TextAnchor.UpperCenter; RectTransform rectTransform = parentObj.transform as RectTransform; rectTransform.anchorMin = new Vector2(0, 1); rectTransform.anchorMax = new Vector2(1, 1); rectTransform.sizeDelta = new Vector2(0, 0); rectTransform.pivot = new Vector2(0.5f, 1); //parentObj.AddComponent<LayoutElement>(); parentObj.AddComponent <ScrollViewContent>().scrollView = scrollView; GameObject child = new GameObject(); child.name = "BSMLScrollViewContentContainer"; child.transform.SetParent(rectTransform, false); VerticalLayoutGroup layoutGroup = child.AddComponent <VerticalLayoutGroup>(); layoutGroup.childControlHeight = false; layoutGroup.childForceExpandHeight = false; layoutGroup.childAlignment = TextAnchor.LowerCenter; layoutGroup.spacing = 0.5f; //parentObj.AddComponent<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize; //child.AddComponent<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize; //child.AddComponent<LayoutElement>(); ExternalComponents externalComponents = child.AddComponent <ExternalComponents>(); externalComponents.components.Add(scrollView); externalComponents.components.Add(scrollView.transform); externalComponents.components.Add(gameObject.AddComponent <LayoutElement>()); (child.transform as RectTransform).sizeDelta = new Vector2(0, -1); scrollView.SetField <ScrollView, RectTransform>("_contentRectTransform", parentObj.transform as RectTransform); gameObject.SetActive(true); return(child); }
// TODO optimize public void Update() { float leftOffset = Left; foreach (var item in left) { if (item != null && item.gameObject.activeSelf) { leftOffset += item.rect.width; } } float rightOffset = Right; foreach (var item in right) { if (item != null && item.gameObject.activeSelf) { rightOffset += item.rect.width; } } float topOffset = Top; foreach (var item in top) { if (item != null && item.gameObject.activeSelf) { topOffset += item.rect.height; } } float bottomOffset = Bottom; foreach (var item in bottom) { if (item != null && item.gameObject.activeSelf) { bottomOffset += item.rect.height; } } VerticalLayoutGroup vertical = transform.parent.GetComponent <VerticalLayoutGroup>(); HorizontalLayoutGroup horizontal = transform.parent.GetComponent <HorizontalLayoutGroup>(); layoutElement = GetComponent <LayoutElement>(); if (vertical != null) { var vertRT = vertical.GetComponent <RectTransform>(); if (vertRT != null) { var newHeight = vertRT.rect.height - topOffset - bottomOffset - GetLayoutGroupOffset(vertical); if (layoutElement != null) { layoutElement.minHeight = newHeight; } rt.SetHeight(newHeight); } } else if (horizontal != null) { var horizRT = horizontal.GetComponent <RectTransform>(); if (horizRT != null) { var newWidth = horizRT.rect.width - leftOffset - rightOffset - GetLayoutGroupOffset(horizontal); if (layoutElement != null) { layoutElement.minWidth = newWidth; } rt.SetWidth(newWidth); } } else { rt.anchorMin = Vector2.zero; rt.anchorMax = Vector2.one; rt.pivot = Vector2.one / 2; rt.SetLeft(leftOffset); rt.SetRight(rightOffset); rt.SetTop(topOffset); rt.SetBottom(bottomOffset); } }
void Awake() { MonoBehaviour.print ("Awake files"); verticalLG = GetComponent<VerticalLayoutGroup> (); directory = new DirectoryInfo ("Assets//docs//Action_information"); list_of_file = new List<File_Input> (); //StartCoroutine ("_RefreshFile"); RefreshFile(); }
public void OnEnable() { RoomName.text = lobbyManager.roomName; _instance = this; _layout = playerListContentTransform.GetComponent <VerticalLayoutGroup>(); }
private void Start() { group = GetComponent <VerticalLayoutGroup>(); bar = transform.parent.parent.Find("Scrollbar").GetComponent <Scrollbar>(); bar.numberOfSteps = 256; }
private void Awake() { _canvas = GetComponentInParent <Canvas>(); _layoutGroup = GetComponent <VerticalLayoutGroup>(); }
public LayoutGroupSettings(VerticalLayoutGroup e) { padding = e.padding; spacing = e.spacing; }
public static GameObject NewScrollView(Vector2 size = default(Vector2), BarType barType = BarType.None, ContentType contentType = ContentType.VerticalLayout, Vector2 spacing = default(Vector2), Vector2 gridSize = default(Vector2)) { //创建ScrollRect GameObject go1 = new GameObject("ScrollView", new System.Type[] { typeof(RectTransform), typeof(ScrollRect) }); go1.layer = 0; RectTransform tf1 = go1.GetComponent <RectTransform>(); tf1.anchoredPosition = new Vector2(0, 0); tf1.sizeDelta = size == default(Vector2) ? new Vector2(100, 100) : size; ScrollRect scrollRect = go1.GetComponent <ScrollRect>(); scrollRect.horizontal = false; //创建Viewport GameObject go2 = new GameObject("Viewport", new System.Type[] { typeof(RectTransform), typeof(Mask), typeof(Image) }); go2.layer = 0; RectTransform tf2 = go2.GetComponent <RectTransform>(); tf2.SetParent(tf1, false); tf2.anchorMin = new Vector2(0, 0); tf2.anchorMax = new Vector2(1, 1); tf2.anchoredPosition = new Vector2(0, 0); tf2.sizeDelta = new Vector2(-17, -17); tf2.pivot = new Vector2(0, 1); Image image2 = go2.GetComponent <Image>(); image2.color = new Color(0.5568628f, 0.5568628f, 0.5568628f); Mask mask = go2.GetComponent <Mask>(); mask.showMaskGraphic = false; //创建Content GameObject go3 = new GameObject("Content", new System.Type[] { typeof(RectTransform), typeof(ContentSizeFitter) }); go3.layer = 0; RectTransform tf3 = go3.GetComponent <RectTransform>(); tf3.SetParent(tf2, false); tf3.anchorMin = new Vector2(0, 1); tf3.anchorMax = new Vector2(1, 1); tf3.anchoredPosition = new Vector2(0, 0); tf3.sizeDelta = new Vector2(0, 0); tf3.pivot = new Vector2(0.5f, 1); ContentSizeFitter contentSizeFitter = tf3.GetComponent <ContentSizeFitter>(); contentSizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; switch (contentType) { case ContentType.Grid: GridLayoutGroup gridLayoutGroup = go3.AddComponent <GridLayoutGroup>(); gridLayoutGroup.cellSize = gridSize == default(Vector2) ? new Vector2(100, 100) : gridSize; gridLayoutGroup.spacing = spacing; break; case ContentType.VerticalLayout: VerticalLayoutGroup verticalLayoutGroup = go3.AddComponent <VerticalLayoutGroup>(); verticalLayoutGroup.spacing = spacing.y; verticalLayoutGroup.childControlHeight = false; verticalLayoutGroup.childControlWidth = false; verticalLayoutGroup.childForceExpandHeight = false; verticalLayoutGroup.childForceExpandWidth = false; verticalLayoutGroup.childAlignment = TextAnchor.UpperCenter; break; default: break; } //关联控件 scrollRect.viewport = tf2; scrollRect.content = tf3; switch (barType) { case BarType.Vertical: GameObject go4 = new GameObject("ScrollbarVertical", new System.Type[] { typeof(RectTransform), typeof(Image), typeof(Scrollbar) }); go4.layer = 0; RectTransform tf4 = go4.GetComponent <RectTransform>(); tf4.SetParent(tf1, false); tf4.anchorMin = new Vector2(1, 0); tf4.anchorMax = new Vector2(1, 1); tf4.anchoredPosition = new Vector2(0, 0); tf4.sizeDelta = new Vector2(20, 0); tf4.pivot = new Vector2(1, 1); Image image4 = go4.GetComponent <Image>(); image4.sprite = default(Sprite); image4.color = new Color(0.9490196f, 0.509803951f, 0.503921571f); Scrollbar scrollbar = go4.GetComponent <Scrollbar>(); scrollbar.direction = Scrollbar.Direction.BottomToTop; GameObject go5 = new GameObject("SlidingArea", new System.Type[] { typeof(RectTransform) }); go5.layer = 0; RectTransform tf5 = go5.GetComponent <RectTransform>(); tf5.SetParent(tf4, false); tf5.anchorMin = new Vector2(0, 0); tf5.anchorMax = new Vector2(1, 1); tf5.anchoredPosition = new Vector2(0, 0); tf5.sizeDelta = new Vector2(-20, -20); tf5.pivot = new Vector2(0.5f, 0.5f); GameObject go6 = new GameObject("Handle", new System.Type[] { typeof(RectTransform), typeof(Image) }); go6.layer = 0; RectTransform tf6 = go6.GetComponent <RectTransform>(); tf6.SetParent(tf5, false); tf6.anchorMin = new Vector2(0, 0.5f); tf6.anchorMax = new Vector2(1, 1); tf6.anchoredPosition = new Vector2(0, 0); tf6.sizeDelta = new Vector2(20, 20); tf6.pivot = new Vector2(0.5f, 0.5f); Image image6 = go6.GetComponent <Image>(); image6.sprite = default(Sprite); image6.color = new Color(0.9490196f, 0.509803951f, 0.503921571f); scrollbar.targetGraphic = image6; scrollbar.handleRect = tf6; scrollRect.verticalScrollbar = scrollbar; scrollRect.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport; scrollRect.verticalScrollbarSpacing = -3; break; default: break; } return(go1); }
public void Refresh(ChatLogParam param, ChatWindow.MessageTemplateType type) { if (param == null) { return; } if (this.mCoroutine != null) { this.StopCoroutine(this.mCoroutine); this.mCoroutine = (Coroutine)null; } if (UnityEngine.Object.op_Equality((UnityEngine.Object) this.mRoot, (UnityEngine.Object)null)) { if (!UnityEngine.Object.op_Inequality((UnityEngine.Object)((Component)this).get_transform().get_parent(), (UnityEngine.Object)null)) { return; } this.mRoot = ((Component)((Component)this).get_transform().get_parent()).get_gameObject(); } this.MessageIcon.SetActive(false); this.MessageLog.SetActive(false); this.MyMessageIcon.SetActive(false); this.MyMessageLog.SetActive(false); this.SystemMessageRootObj.SetActive(false); switch (type) { case ChatWindow.MessageTemplateType.OtherUser: this.MessageIcon.SetActive(true); this.MessageLog.SetActive(true); this.mStampRoot = !UnityEngine.Object.op_Inequality((UnityEngine.Object) this.AnyStampObj, (UnityEngine.Object)null) ? (Transform)null : this.AnyStampObj.get_transform(); this.mNameObj = this.AnyNameObj; this.mFuIDObj = this.AnyFuIDObj; this.mPostAtObj = this.AnyPostAtObj; this.mStampImageObj = this.AnyStampImageObj; this.mMessageObj = this.AnyMessageTextObj; this.mLogRoot = this.AnyLogRoot; this.mLogImg = (Image)((Component)this.AnyLogRoot).GetComponent <Image>(); break; case ChatWindow.MessageTemplateType.User: this.MyMessageIcon.SetActive(true); this.MyMessageLog.SetActive(true); this.mStampRoot = !UnityEngine.Object.op_Inequality((UnityEngine.Object) this.MyStampObj, (UnityEngine.Object)null) ? (Transform)null : this.MyStampObj.get_transform(); this.mNameObj = this.MyNameObj; this.mFuIDObj = this.MyFuIDObj; this.mPostAtObj = this.MyPostAtObj; this.mStampImageObj = this.MyStampImageObj; this.mMessageObj = this.MyMessageTextObj; this.mLogRoot = this.MyLogRoot; this.mLogImg = (Image)((Component)this.MyLogRoot).GetComponent <Image>(); break; case ChatWindow.MessageTemplateType.System: this.SystemMessageRootObj.SetActive(true); this.SystemMessageTextObj.set_text(param.message); this.mCoroutine = this.StartCoroutine(this.RefreshTextLine(param.message)); return; } if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.Icon, (UnityEngine.Object)null) && UnityEngine.Object.op_Inequality((UnityEngine.Object) this.LeftIcon, (UnityEngine.Object)null) && UnityEngine.Object.op_Inequality((UnityEngine.Object) this.RightIcon, (UnityEngine.Object)null)) { RawImage target = type != ChatWindow.MessageTemplateType.User ? this.LeftIcon : this.RightIcon; UnitParam unitParam = MonoSingleton <GameManager> .Instance.MasterParam.GetUnitParam(param.icon); if (unitParam != null) { if (!string.IsNullOrEmpty(param.skin_iname) && UnityEngine.Object.op_Inequality((UnityEngine.Object)target, (UnityEngine.Object)null)) { ArtifactParam skin = Array.Find <ArtifactParam>(MonoSingleton <GameManager> .Instance.MasterParam.Artifacts.ToArray(), (Predicate <ArtifactParam>)(p => p.iname == param.skin_iname)); MonoSingleton <GameManager> .Instance.ApplyTextureAsync(target, AssetPath.UnitSkinIconSmall(unitParam, skin, param.job_iname)); } else { MonoSingleton <GameManager> .Instance.ApplyTextureAsync(target, AssetPath.UnitIconSmall(unitParam, param.job_iname)); } } } if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.mNameObj, (UnityEngine.Object)null)) { this.mNameObj.set_text(param.name); } if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.mFuIDObj, (UnityEngine.Object)null)) { this.mFuIDObj.set_text(LocalizedText.Get("sys.TEXT_CHAT_FUID", new object[1] { (object)param.fuid.Substring(param.fuid.Length - 4, 4) })); } if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.mPostAtObj, (UnityEngine.Object)null)) { this.mPostAtObj.set_text(ChatLogItem.GetPostAt(param.posted_at)); } if ((int)param.message_type == 1) { if (!UnityEngine.Object.op_Inequality((UnityEngine.Object) this.mRoot, (UnityEngine.Object)null) || !this.mRoot.get_activeInHierarchy()) { return; } if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.mStampRoot, (UnityEngine.Object)null)) { ((Component)this.mStampRoot).get_gameObject().SetActive(false); } this.mCoroutine = this.StartCoroutine(this.RefreshTextLine(param.message)); } else { if ((int)param.message_type != 2 || !UnityEngine.Object.op_Inequality((UnityEngine.Object) this.mRoot, (UnityEngine.Object)null) || !this.mRoot.get_activeInHierarchy()) { return; } if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.mStampRoot, (UnityEngine.Object)null)) { ((Component)this.mStampRoot).get_gameObject().SetActive(true); } if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.Element, (UnityEngine.Object)null)) { int stampSize = this.STAMP_SIZE; VerticalLayoutGroup component = (VerticalLayoutGroup)((Component)this.mLogRoot).GetComponent <VerticalLayoutGroup>(); this.Element.set_minHeight((float)(stampSize + ((LayoutGroup)component).get_padding().get_top() + ((LayoutGroup)component).get_padding().get_bottom() + (int)Mathf.Abs((float)this.mLogRoot.get_anchoredPosition().y))); } ((Behaviour)this.mLogImg).set_enabled(false); this.mCoroutine = this.StartCoroutine(this.RefreshStamp(param.stamp_id)); } }
protected override void Awake() { base.Awake(); if (m_virtualContent == null) { return; } m_virtualContentTransformChangeListener = m_virtualContent.GetComponent <RectTransformChangeListener>(); m_virtualContentTransformChangeListener.RectTransformChanged += OnVirtualContentTransformChaged; UpdateVirtualContentPosition(); if (m_mode == VirtualizingMode.Horizontal) { //In horizontal mode we destroy VerticalLayoutGroup if exists VerticalLayoutGroup verticalLayout = m_virtualContent.GetComponent <VerticalLayoutGroup>(); if (verticalLayout != null) { DestroyImmediate(verticalLayout); } // Create HorizontalLayoutGroup if does not exists HorizontalLayoutGroup horizontalLayout = m_virtualContent.GetComponent <HorizontalLayoutGroup>(); if (horizontalLayout == null) { horizontalLayout = m_virtualContent.gameObject.AddComponent <HorizontalLayoutGroup>(); } // Setup HorizontalLayoutGroup behavior to arrange ui containers correctly horizontalLayout.childControlHeight = true; horizontalLayout.childControlWidth = false; horizontalLayout.childForceExpandWidth = false; } else { //In horizontal mode we destroy HorizontalLayoutGroup if exists HorizontalLayoutGroup horizontalLayout = m_virtualContent.GetComponent <HorizontalLayoutGroup>(); if (horizontalLayout != null) { DestroyImmediate(horizontalLayout); } // Create VerticalLayoutGroup if does not exists VerticalLayoutGroup verticalLayout = m_virtualContent.GetComponent <VerticalLayoutGroup>(); if (verticalLayout == null) { verticalLayout = m_virtualContent.gameObject.AddComponent <VerticalLayoutGroup>(); } // Setup VerticalLayoutGroup behavior to arrange ui containers correctly verticalLayout.childControlWidth = true; verticalLayout.childControlHeight = false; verticalLayout.childForceExpandHeight = false; } // Set ScrollSensitivity to be exactly the same as ContainerSize scrollSensitivity = ContainerSize; }
private void Start() { _layoutGroup = GetComponent <VerticalLayoutGroup>(); }
private void Awake() { _grandParent = transform.parent.parent; verticalLayoutGroup = GetComponentInParent <VerticalLayoutGroup>(); contentSizeFitter = _grandParent.GetComponent <ContentSizeFitter>(); }
// Use this for initialization void Start() { vlg = GetComponent <VerticalLayoutGroup>(); score = Main.instance.score; SetAvaliableLevels(); }
override protected void Awake() { base.Awake(); rectTransform = GetComponent <RectTransform>(); verticalLayoutGroup = GetComponent <VerticalLayoutGroup>(); }
public override void InitDropdown(VerticalLayoutGroup layoutGroupToBeDisabled, GameObject canvasRoot) { base.InitDropdown(layoutGroupToBeDisabled, canvasRoot); DropdownParameter.Init(layoutGroupToBeDisabled, canvasRoot, type); }
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; } }
public MorphSearch(BaseModule baseModule) { UI ui = baseModule.ui; Transform moduleUI = baseModule.moduleUI; Atom atom = baseModule.atom; searchBox = ui.CreateTextInput("Search For Morph", 800, 100, moduleUI); searchBox.transform.localPosition = new Vector3(0, -110, 0); paginationSlider = ui.CreateSlider("Page", 930, 80, true, moduleUI); paginationSlider.transform.localPosition = new Vector3(0, -200, 0); paginationValue = new JSONStorableFloat("Page", 0, (float value) => { }, 0, 10, true, true); paginationSlider.valueFormat = "n0"; paginationValue.slider = paginationSlider.slider; paginationSlider.gameObject.SetActive(false); GridLayoutGroup layout = ui.CreateGridLayout(1200, 800, moduleUI); layout.transform.localPosition = new Vector3(0, -1010, 0); layout.constraintCount = 3; layout.constraint = GridLayoutGroup.Constraint.FixedColumnCount; layout.GetComponent <RectTransform>().pivot = new Vector2(0, 0); layout.cellSize = new Vector2(400, 80); for (int i = 0; i < MAX_MORPHS_PER_PAGE - 1; i++) { UIDynamicSlider slider = ui.CreateMorphSlider("Slider " + i, 400, 80, moduleUI); slider.transform.SetParent(layout.transform, false); morphSliders.Add(slider); slider.gameObject.SetActive(false); } DAZCharacterSelector personGeometry = atom.GetStorableByID("geometry") as DAZCharacterSelector; morphControl = personGeometry.morphsControlUI; regions = new HashSet <string>(); morphControl.GetMorphDisplayNames().ForEach((name) => { DAZMorph morph = morphControl.GetMorphByDisplayName(name); regions.Add(morph.region); }); morphNames = morphControl.GetMorphDisplayNames(); searchBox.onValueChanged.AddListener(UpdateSearch); UIDynamicButton clearButton = ui.CreateButton("Clear", 120, 100, moduleUI); clearButton.transform.localPosition = new Vector3(810, -110, 0); clearButton.button.onClick.AddListener(() => { searchBox.text = ""; ClearSearch(); }); VerticalLayoutGroup commonTermsGroup = ui.CreateVerticalLayout(220, 0, moduleUI); commonTermsGroup.transform.localPosition = new Vector3(-230, -200, 0); commonTermsGroup.GetComponent <RectTransform>().pivot = new Vector2(0, 0); commonTermsGroup.childAlignment = TextAnchor.UpperLeft; for (int i = 0; i < MAX_TERMS; i++) { UIDynamicButton termButton = ui.CreateButton("Term", 220, 40, moduleUI); termButton.transform.SetParent(commonTermsGroup.transform, false); termButtons.Add(termButton); UI.ColorButton(termButton, Color.white, new Color(0.3f, 0.4f, 0.6f)); termButton.gameObject.SetActive(false); ContentSizeFitter csf = termButton.gameObject.AddComponent <ContentSizeFitter>(); csf.verticalFit = ContentSizeFitter.FitMode.MinSize; } //Debug.Log("----------------------------"); //UIDynamicSlider testSlider = ui.CreateMorphSlider("test"); //ui.DebugDeeper(testSlider.transform); }
VerticalLayoutGroup layout ; //布局 protected override void InitLayoutInfo () { layout = GetComponentInChildren<VerticalLayoutGroup>() ; layoutRect = layout.GetComponent<RectTransform>() ; }
public void Initialize() { vr = viewer.GetComponent <VerticalLayoutGroup>(); scrollbar = this.GetComponent <Scrollbar>(); scrollbar.size = 1f / MaxSize; }
override protected void Awake() { base.Awake(); rectTransform = GetComponent<RectTransform>(); verticalLayoutGroup = GetComponent<VerticalLayoutGroup>(); }
public void OnEnable() { _instance = this; _layout = playerListContentTransform.GetComponent<VerticalLayoutGroup>(); }
private static ScrollRect CreateUIScrollview(Layer layer) { Layer backgroundLayer = layer.GetImageChild("|Background"); if (backgroundLayer == null) { Debug.LogError("创建scrollView出错,图层 " + layer.Name + "中 缺少 |Background 标签"); return(null); } ScrollRect scrollRect = null; backgroundLayer.Name = backgroundLayer.Name.ReplaceIgnoreCase("|Background", string.Empty).Trim(); Image backgroundImg = CreateUIImage(backgroundLayer); backgroundImg.name = layer.Name.Trim(); scrollRect = backgroundImg.gameObject.AddComponent <ScrollRect>(); // viewport GameObject viewPort = new GameObject("ViewPort"); viewPort.AddComponent <RectTransform>(); viewPort.transform.SetParent(backgroundImg.transform, false); Image maskImgae = viewPort.AddComponent <Image>(); maskImgae.sprite = CreateSprite(backgroundLayer); maskImgae.type = Image.Type.Sliced; RectTransform rectViewPort = viewPort.GetComponent <RectTransform>(); rectViewPort.sizeDelta = backgroundImg.GetComponent <RectTransform>().sizeDelta; rectViewPort.anchorMin = new Vector2(0, 0); rectViewPort.anchorMax = new Vector2(1, 1); rectViewPort.offsetMin = new Vector2(0, 0); rectViewPort.offsetMax = new Vector2(0, 0); viewPort.AddComponent <UnityEngine.UI.Mask>(); // Content GameObject content = new GameObject("Content"); viewPort.AddComponent <RectTransform>(); content.transform.SetParent(viewPort.transform); VerticalLayoutGroup verticalLayerGroup = content.AddComponent <VerticalLayoutGroup>(); verticalLayerGroup.spacing = 10; verticalLayerGroup.childForceExpandWidth = true; verticalLayerGroup.childForceExpandHeight = false; RectTransform rectContent = content.GetComponent <RectTransform>(); rectContent.anchorMin = new Vector2(0, 1); rectContent.anchorMax = new Vector2(1, 1); rectContent.pivot = new Vector2(0.5f, 1); rectContent.offsetMax = new Vector2(0, 0); rectContent.offsetMin = new Vector2(0, 0 - backgroundLayer.Rect.height * 1.5f); // scrollrect scrollRect.content = rectContent; scrollRect.viewport = rectViewPort; scrollRect.vertical = true; scrollRect.horizontal = false; GameObject.DestroyImmediate(backgroundImg); GameObject oldGroupObject = currentGroupGameObject; foreach (Layer child in layer.Children) { if (child == backgroundLayer) { continue; } if (child.Name.ContainsIgnoreCase("|Element")) { child.Name = child.Name.ReplaceIgnoreCase("|Element", string.Empty).Trim(); currentGroupGameObject = content; } else { currentGroupGameObject = scrollRect.gameObject; } if (child.IsTextLayer) { TextMeshProUGUI textChild = CreateUIText(child); AdjustUIRectByLayer(textChild.gameObject, child); } if (child.IsFolderLayer) { ExportFolderLayer(child); } if (child.IsImageLayer) { Image imageChild = CreateUIImage(child); AdjustUIRectByLayer(imageChild.gameObject, child); } } int elementCount = content.transform.childCount; for (int i = 0; i < elementCount; i++) { GameObject childObj = content.transform.GetChild(i).gameObject; RectTransform rect = childObj.GetComponent <RectTransform>(); if (rect != null) { LayoutElement layout = childObj.AddComponent <LayoutElement>(); layout.preferredHeight = rect.sizeDelta.y; layout.preferredWidth = rect.sizeDelta.x; } } currentGroupGameObject = oldGroupObject; return(scrollRect); }
public override void ProcessMouseEvent(Vector2 location, InputManager.LogicalButtonState buttons) { if (Math.Abs(buttons.WheelTick) > 0 && TextLabels.Count > 1) { SetSelectedIndex(SelectedIndex + buttons.WheelTick); } if (!buttons.PrimaryClick || ParentCanvas == null || ParentCanvas.PopupEnabled() || TextLabels.Count < 2) { return; } float width = Rect.GetPixelSize().X; float height = Rect.GetPixelSize().Y; Vector2 origin = Rect.GetPixelOrigin(); float availableDist = width - (height * 2); if (location.X < origin.X + height || location.X > origin.X + availableDist + height) { return; } Vector2 thisOrigin = GetScreenOrigin(); float thisCenterY = thisOrigin.Y + (height * 0.5f); float totalheight = (MenuCommon.ButtonSpacing.Paramater + (height * 1)) * TextLabels.Count; totalheight += MenuCommon.ButtonSpacing.Paramater * 1; float halfHeight = totalheight * 0.5f; float screenHeight = ParentCanvas.BoundWindow.Height; // see where the popup will land on the screen. OriginLocation originAllignment = OriginLocation.LowerLeft; if (totalheight > screenHeight) // it won't fit, center it { originAllignment = OriginLocation.MiddleLeft; } else { if (thisCenterY - halfHeight > 0 && thisCenterY + halfHeight <= screenHeight) { originAllignment = OriginLocation.MiddleLeft; // it'll fit centered, that looks better } else { // it won't fit centered, so put it on the other side of the screen from where the button is if (thisCenterY > halfHeight) { originAllignment = OriginLocation.UpperLeft; } else { originAllignment = OriginLocation.LowerLeft; } } } if (originAllignment == OriginLocation.UpperLeft) { thisOrigin.Y += height; } else if (originAllignment == OriginLocation.MiddleLeft) { thisOrigin.Y += height * 0.5f; } RelativeRect rect = new RelativeRect(new RelativeLoc(thisOrigin.X, RelativeLoc.Edge.Raw), new RelativeLoc(thisOrigin.Y, RelativeLoc.Edge.Raw), RelativeSize.FixedPixelSize(width), RelativeSize.FixedPixelSize(totalheight), originAllignment); var popup = new UIPanel(rect, ThemeManager.GetThemeAsset("ui/SelectorPopupBackground.png")); popup.FillMode = UIFillModes.SmartStprite; popup.IgnoreMouse = false; VerticalLayoutGroup vertgroup = MenuCommon.SetupCommonColumn(new RelativeRect(RelativeLoc.XCenter, RelativeLoc.YCenter, RelativeSize.ThreeQuarterWidth, rect.Height, OriginLocation.Center)); vertgroup.FirstElementHasSpacing = true; foreach (var label in TextLabels) { MenuButton button = new MenuButton(new RelativeRect(), label); button.Tag = label; button.Clicked += PopupButton_Clicked; if (label == GetText()) { button.Check(); } vertgroup.AddChild(button); } popup.AddChild(vertgroup); ParentCanvas.SetPopupElement(popup); }
// Use this for initialization void Awake() { destroyTheChildren = new List<GameObject> (); layout = GetComponent<VerticalLayoutGroup> (); }