public static void CreatePanel(MenuCommand menuCommand) { GameObject go = CreateUIElementRoot("Panel", s_ThickGUIElementSize); ImageExpand image = go.AddComponent <ImageExpand>(); image.type = Image.Type.Sliced; image.sprite = AssetDatabase.GetBuiltinExtraResource <Sprite>(kBackgroundSpriteResourcePath); image.fillCenter = true; image.color = Color.white; ClearRays(image); RectTransform rectTransform = go.GetComponent <RectTransform>(); rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.anchoredPosition = Vector2.zero; rectTransform.sizeDelta = Vector2.zero; PlaceUIElementRoot(go, menuCommand); RectTransform rect = go.GetComponent <RectTransform>(); rect.anchoredPosition = Vector2.zero; rect.sizeDelta = Vector2.zero; }
public static void CreateInputField(MenuCommand command) { GameObject go = CreateUIElementRoot("InputField", command, s_ThickGUIElementSize); GameObject childPlaceholder = CreateObj("Placeholder", go); GameObject childText = CreateObj("Text", go); ImageExpand image = go.AddComponent <ImageExpand>(); image.sprite = AssetDatabase.GetBuiltinExtraResource <Sprite>(kInputFieldBackgroundPath); image.type = Image.Type.Sliced; image.color = Color.white; InputExpand inputField = go.AddComponent <InputExpand>(); ColorBlock colors = inputField.colors; colors.highlightedColor = new Color(0.882f, 0.882f, 0.882f); colors.pressedColor = new Color(0.698f, 0.698f, 0.698f); colors.disabledColor = new Color(0.521f, 0.521f, 0.521f); inputField.colors = colors; TextExpand text = childText.AddComponent <TextExpand>(); text.text = ""; text.supportRichText = false; text.color = new Color(50f / 255f, 50f / 255f, 50f / 255f, 1f); TextExpand placeholder = childPlaceholder.AddComponent <TextExpand>(); placeholder.text = "Kubility"; placeholder.fontStyle = FontStyle.Italic; // Make placeholder color half as opaque as normal text color. Color placeholderColor = text.color; placeholderColor.a *= 0.5f; placeholder.color = placeholderColor; RectTransform textRectTransform = childText.GetComponent <RectTransform>(); textRectTransform.anchorMin = Vector2.zero; textRectTransform.anchorMax = Vector2.one; textRectTransform.sizeDelta = Vector2.zero; textRectTransform.offsetMin = new Vector2(10, 6); textRectTransform.offsetMax = new Vector2(-10, -7); RectTransform placeholderRectTransform = childPlaceholder.GetComponent <RectTransform>(); placeholderRectTransform.anchorMin = Vector2.zero; placeholderRectTransform.anchorMax = Vector2.one; placeholderRectTransform.sizeDelta = Vector2.zero; placeholderRectTransform.offsetMin = new Vector2(10, 6); placeholderRectTransform.offsetMax = new Vector2(-10, -7); inputField.textComponent = text; inputField.placeholder = placeholder; }
static ImageExpand AddImage(GameObject go, Color col, string path = kBackgroundSpriteResourcePath) { ImageExpand image = go.AddComponent <ImageExpand>(); image.type = Image.Type.Tiled; image.sprite = AssetDatabase.GetBuiltinExtraResource <Sprite>(path); image.fillCenter = true; image.color = col; ClearRays(image); return(image); }
public static void CreateImage(MenuCommand commond) { GameObject go = CreateUIElementRoot("Image", commond, s_ImageGUIElementSize); ImageExpand img = go.AddComponent <ImageExpand>(); img.type = Image.Type.Simple; ClearRays(img); SetParentAndAlign(go, Selection.activeGameObject); Selection.activeObject = go; }
public static void CreateScrollbar(MenuCommand command) { GameObject go = CreateUIElementRoot("Scrollbar", command, s_ThinGUIElementSize); GameObject sliderArea = CreateObj("Sliding Area", go); GameObject handle = CreateObj("Handle", sliderArea); ImageExpand bgImage = go.AddComponent <ImageExpand>(); bgImage.sprite = AssetDatabase.GetBuiltinExtraResource <Sprite>(kBackgroundSpriteResourcePath); bgImage.type = Image.Type.Sliced; bgImage.color = whiteColor; ClearRays(bgImage); ImageExpand handleImage = handle.AddComponent <ImageExpand>(); handleImage.sprite = AssetDatabase.GetBuiltinExtraResource <Sprite>(kStandardSpritePath); handleImage.type = Image.Type.Sliced; handleImage.color = Color.white; ClearRays(handleImage); RectTransform sliderAreaRect = sliderArea.GetComponent <RectTransform>(); sliderAreaRect.sizeDelta = new Vector2(-20, -20); sliderAreaRect.anchorMin = Vector2.zero; sliderAreaRect.anchorMax = Vector2.one; RectTransform handleRect = handle.GetComponent <RectTransform>(); handleRect.sizeDelta = new Vector2(20, 20); ScrollbarExpand scrollbar = go.AddComponent <ScrollbarExpand>(); scrollbar.handleRect = handleRect; scrollbar.targetGraphic = handleImage; ClearRays(scrollbar); ColorBlock colors = scrollbar.colors; colors.highlightedColor = new Color(0.882f, 0.882f, 0.882f); colors.pressedColor = new Color(0.698f, 0.698f, 0.698f); colors.disabledColor = new Color(0.521f, 0.521f, 0.521f); scrollbar.colors = colors; }
public static GameObject CreateScrollbar() { // Create GOs Hierarchy GameObject scrollbarRoot = CreateUIElementRoot("Scrollbar", s_ThickGUIElementSize); GameObject sliderArea = CreateObj("Sliding Area", scrollbarRoot); GameObject handle = CreateObj("Handle", sliderArea); ImageExpand bgImage = scrollbarRoot.AddComponent <ImageExpand>(); bgImage.sprite = AssetDatabase.GetBuiltinExtraResource <Sprite>(kBackgroundSpriteResourcePath); bgImage.type = Image.Type.Sliced; bgImage.color = whiteColor; ImageExpand handleImage = handle.AddComponent <ImageExpand>(); handleImage.sprite = AssetDatabase.GetBuiltinExtraResource <Sprite>(kStandardSpritePath); handleImage.type = Image.Type.Sliced; handleImage.color = whiteColor; RectTransform sliderAreaRect = sliderArea.GetComponent <RectTransform>(); sliderAreaRect.sizeDelta = new Vector2(-20, -20); sliderAreaRect.anchorMin = Vector2.zero; sliderAreaRect.anchorMax = Vector2.one; RectTransform handleRect = handle.GetComponent <RectTransform>(); handleRect.sizeDelta = new Vector2(20, 20); ScrollbarExpand scrollbar = scrollbarRoot.AddComponent <ScrollbarExpand>(); scrollbar.handleRect = handleRect; scrollbar.targetGraphic = handleImage; ColorBlock colors = scrollbar.colors; colors.highlightedColor = new Color(0.882f, 0.882f, 0.882f); colors.pressedColor = new Color(0.698f, 0.698f, 0.698f); colors.disabledColor = new Color(0.521f, 0.521f, 0.521f); return(scrollbarRoot); }
public static List <GameObject> CreateHorGridScroll(this GameObject gameobject, string masksprite, out GameObject scrollObj, Vector2 viewSize, float delta, GameObject prefab, int cnt, UIAlign align = UIAlign.CENTER, int collimit = -1, int rowlimit = -1, UIPluginType uitype = defaultType) { if (uitype == UIPluginType.UGUI) { GameObject scrollgameobject = gameobject.TryGetGameObject("Scroll"); scrollObj = scrollgameobject; float totalx = 0f; if (prefab != null) { totalx = (prefab.GetComponent <RectTransform>().sizeDelta.x + delta) * cnt; } ScrollViewExpand rect = scrollgameobject.TryAddComponent <ScrollViewExpand>(); rect.vertical = false; rect.horizontal = true; rect.movementType = ScrollRect.MovementType.Elastic; rect.inertia = true; //rect.horizontalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport; //rect.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport; rect.GetComponent <RectTransform>().sizeDelta = viewSize; GameObject viewPortgameobject = scrollgameobject.TryGetGameObject("Viewport"); GameObject Gridgameobject = viewPortgameobject.TryGetGameObject("Grid"); Mask viewmask = viewPortgameobject.TryAddComponent <Mask>(); viewmask.showMaskGraphic = false; ImageExpand viewimage = viewPortgameobject.TryAddComponent <ImageExpand>(); viewimage.raycastTarget = true; viewimage.type = Image.Type.Sliced; viewimage.fillCenter = true; if (SpriteAtlasMgr.mIns != null) { SpriteAtlasMgr.mIns.ChangeSprite(viewimage, masksprite); } GridLayoutGroup group = Gridgameobject.TryAddComponent <GridLayoutGroup>(); group.spacing = new Vector2(delta, 0); group.startCorner = GridLayoutGroup.Corner.UpperLeft; group.startAxis = GridLayoutGroup.Axis.Horizontal; RectTransform grouprect = group.GetComponent <RectTransform>(); grouprect.sizeDelta = new Vector2(totalx, 0); grouprect.anchorMin = new Vector2(0, 1); grouprect.anchorMax = new Vector2(1, 1); grouprect.pivot = new Vector2(0, 1); if (collimit != -1 && collimit >= 0) { group.constraint = GridLayoutGroup.Constraint.FixedColumnCount; group.constraintCount = collimit; } else if (rowlimit != -1 && rowlimit >= 0) { group.constraint = GridLayoutGroup.Constraint.FixedRowCount; group.constraintCount = rowlimit; } if (align == UIAlign.CENTER) { group.childAlignment = TextAnchor.MiddleCenter; } else if (align == UIAlign.CENTER_DOWN) { group.childAlignment = TextAnchor.LowerCenter; } else if (align == UIAlign.CENTER_TOP) { group.childAlignment = TextAnchor.UpperCenter; } else if (align == UIAlign.LEFT_DOWN) { group.childAlignment = TextAnchor.LowerLeft; } else if (align == UIAlign.LEFT_TOP) { group.childAlignment = TextAnchor.UpperLeft; } else if (align == UIAlign.RIGHT_DOWN) { group.childAlignment = TextAnchor.LowerRight; } else if (align == UIAlign.RIGHT_TOP) { group.childAlignment = TextAnchor.UpperRight; } List <GameObject> gameObjectList = null; if (cnt > 0) { gameObjectList = ListPool.TrySpawn <List <GameObject> >(); for (int i = 0; i < cnt; ++i) { GameObject childgameobject = GameObject.Instantiate(prefab); if (i == 0) { RectTransform childrect = childgameobject.GetComponent <RectTransform>(); if (childrect != null) { group.cellSize = childrect.sizeDelta; } } Gridgameobject.AddInstance(childgameobject); gameObjectList.Add(childgameobject); } } RectTransform viewrecttransform = viewPortgameobject.GetComponent <RectTransform>(); viewrecttransform.anchorMin = Vector2.zero; viewrecttransform.anchorMax = new Vector2(1, 1); viewrecttransform.pivot = new Vector2(0, 1); viewrecttransform.sizeDelta = Vector2.zero; rect.content = grouprect; rect.viewport = viewrecttransform; return(gameObjectList); } scrollObj = null; return(null); }
public static void CreateScrollView(MenuCommand command) { GameObject go = CreateObj("Scroll View", Selection.activeObject); GameObject viewport = CreateObj("Viewport", go); GameObject content = CreateObj("Content", viewport); GameObject Hor_Scrollbar = CreateObj("Hor_Scrollbar", go); GameObject HS_sliderArea = CreateObj("Sliding Area", Hor_Scrollbar); GameObject HS_handle = CreateObj("Handle", HS_sliderArea); GameObject Ver_Scrollbar = CreateObj("Ver_Scrollbar", go); GameObject VS_sliderArea = CreateObj("Slideing Area", Ver_Scrollbar); GameObject VS_handle = CreateObj("Handle", VS_sliderArea); RectTransform TotalRect = go.GetComponent <RectTransform>(); TotalRect.sizeDelta = new Vector2(200, 200); RectTransform viewRect = SetRectTransForm(viewport, new Vector2(0, 0), new Vector2(1, 1), new Vector2(0, 1)); viewRect.sizeDelta = new Vector2(-17, -17); //content RectTransform conRect = content.GetComponent <RectTransform>(); conRect.sizeDelta = new Vector2(0, 300); conRect.anchorMin = new Vector2(0, 1); conRect.anchorMax = new Vector2(1, 1); conRect.pivot = new Vector2(0, 1); //Hor scorllbar ScrollbarExpand hbar = Hor_Scrollbar.AddComponent <ScrollbarExpand>(); ClearRays(hbar); AddImage(Hor_Scrollbar, Color.white); ImageExpand hs_hanlder_image = AddImage(HS_handle, Color.white, kStandardSpritePath); ClearRays(hs_hanlder_image); hbar.targetGraphic = hs_hanlder_image; hbar.handleRect = HS_handle.GetComponent <RectTransform>(); var hbarRect = SetRectTransForm(Hor_Scrollbar, new Vector2(0, 0), new Vector2(1, 0), new Vector2(0, 0)); var hbarArea = SetRectTransForm(HS_sliderArea, new Vector2(0, 0), new Vector2(1, 1), new Vector2(0.5f, 0.5f)); var hsRect = SetRectTransForm(HS_handle, new Vector2(0, 0), new Vector2(1, 1), new Vector2(0.5f, 0.5f)); hbarRect.sizeDelta = new Vector2(-17, 20); hbarArea.sizeDelta = new Vector2(-20, -20); hsRect.sizeDelta = new Vector2(20, 20); //Ver scorllbar ScrollbarExpand vbar = Ver_Scrollbar.AddComponent <ScrollbarExpand>(); vbar.direction = Scrollbar.Direction.BottomToTop; ClearRays(vbar); AddImage(Ver_Scrollbar, Color.white); vbar.handleRect = VS_handle.GetComponent <RectTransform>(); ImageExpand vs_hanlder_image = AddImage(VS_handle, Color.white, kStandardSpritePath); vbar.targetGraphic = vs_hanlder_image; ClearRays(vs_hanlder_image); var vsbarRect = SetRectTransForm(Ver_Scrollbar, new Vector2(1, 0), new Vector2(1, 1), new Vector2(1, 1)); var vsbarArea = SetRectTransForm(VS_sliderArea, new Vector2(0, 0), new Vector2(1, 1), new Vector2(0.5f, 0.5f)); var vsRect = SetRectTransForm(VS_handle, new Vector2(0, 0), new Vector2(1, 1), new Vector2(0.5f, 0.5f)); vsbarRect.sizeDelta = new Vector2(20, -17); vsbarArea.sizeDelta = new Vector2(-20, -20); vsRect.sizeDelta = new Vector2(20, 20); //scroll ScrollViewExpand scroll = go.AddComponent <ScrollViewExpand>(); scroll.horizontalScrollbar = hbar; scroll.horizontalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport; scroll.horizontalScrollbarSpacing = -3; scroll.verticalScrollbar = vbar; scroll.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport; scroll.verticalScrollbarSpacing = -3; scroll.content = content.GetComponent <RectTransform>(); ClearRays(scroll); ImageExpand image = go.AddComponent <ImageExpand>(); image.sprite = AssetDatabase.GetBuiltinExtraResource <Sprite>(kBackgroundSpriteResourcePath); image.color = whiteColor; image.type = Image.Type.Sliced; image.fillCenter = true; ClearRays(image); viewport.AddComponent <Mask>().showMaskGraphic = false; ImageExpand vimage = viewport.AddComponent <ImageExpand>(); vimage.sprite = AssetDatabase.GetBuiltinExtraResource <Sprite>(kBackgroundSpriteResourcePath); vimage.color = whiteColor; vimage.type = Image.Type.Sliced; vimage.fillCenter = true; ClearRays(vimage); scroll.viewport = viewRect; PlaceUIElementRoot(go, command); }
public static void CreateSlider(MenuCommand command) { GameObject go = CreateUIElementRoot("Slider", command, s_ThinGUIElementSize); GameObject background = CreateObj("Background", go); GameObject fillArea = CreateObj("Fill Area", go); GameObject fill = CreateObj("Fill", fillArea); GameObject handleArea = CreateObj("Handle Slide Area", go); GameObject handle = CreateObj("Handle", handleArea); // Background var backgroundimg = background.TryAddComponent <ImageExpand>(); backgroundimg.sprite = AssetDatabase.GetBuiltinExtraResource <Sprite>(kBackgroundSpriteResourcePath); backgroundimg.type = Image.Type.Sliced; backgroundimg.color = Color.white; RectTransform backgroundRect = background.GetComponent <RectTransform>(); backgroundRect.anchorMin = new Vector2(0, 0.25f); backgroundRect.anchorMax = new Vector2(1, 0.75f); backgroundRect.sizeDelta = new Vector2(0, 0); // Fill Area RectTransform fillAreaRect = fillArea.GetComponent <RectTransform>(); fillAreaRect.anchorMin = new Vector2(0, 0.25f); fillAreaRect.anchorMax = new Vector2(1, 0.75f); fillAreaRect.anchoredPosition = new Vector2(-5, 0); fillAreaRect.sizeDelta = new Vector2(-20, 0); // Fill ImageExpand fillImage = fill.AddComponent <ImageExpand>(); fillImage.sprite = AssetDatabase.GetBuiltinExtraResource <Sprite>(kStandardSpritePath); fillImage.type = Image.Type.Sliced; fillImage.color = Color.white; RectTransform fillRect = fill.GetComponent <RectTransform>(); fillRect.sizeDelta = new Vector2(10, 0); // Handle Area RectTransform handleAreaRect = handleArea.GetComponent <RectTransform>(); handleAreaRect.sizeDelta = new Vector2(-20, 0); handleAreaRect.anchorMin = new Vector2(0, 0); handleAreaRect.anchorMax = new Vector2(1, 1); // Handle ImageExpand handleImage = handle.TryAddComponent <ImageExpand>(); fillImage.sprite = AssetDatabase.GetBuiltinExtraResource <Sprite>(kKnobPath); fillImage.type = Image.Type.Sliced; fillImage.color = Color.white; RectTransform handleRect = handle.GetComponent <RectTransform>(); handleRect.sizeDelta = new Vector2(20, 0); // Setup slider component SliderExpand slider = go.AddComponent <SliderExpand>(); ClearRays(slider); slider.fillRect = fill.GetComponent <RectTransform>(); slider.handleRect = handle.GetComponent <RectTransform>(); slider.targetGraphic = handleImage; slider.direction = Slider.Direction.LeftToRight; ColorBlock colors = slider.colors; colors.highlightedColor = new Color(0.882f, 0.882f, 0.882f); colors.pressedColor = new Color(0.698f, 0.698f, 0.698f); colors.disabledColor = new Color(0.521f, 0.521f, 0.521f); slider.colors = colors; //handleImage handleImage.raycastTarget = true; }
public static void CreateDropdown(MenuCommand command) { GameObject root = CreateUIElementRoot("Dropdown", command, s_ThickGUIElementSize); GameObject label = CreateObj("Label", root); GameObject arrow = CreateObj("Arrow", root); GameObject template = CreateObj("Template", root); GameObject viewport = CreateObj("Viewport", template); GameObject content = CreateObj("Content", viewport); GameObject item = CreateObj("Item", content); GameObject itemBackground = CreateObj("Item Background", item); GameObject itemCheckmark = CreateObj("Item Checkmark", item); GameObject itemLabel = CreateObj("Item Label", item); // Sub controls. GameObject scrollbar = CreateScrollbar(); scrollbar.name = "Scrollbar"; SetParentAndAlign(scrollbar, template); ScrollbarExpand scrollbarScrollbar = scrollbar.GetComponent <ScrollbarExpand>(); scrollbarScrollbar.SetDirection(Scrollbar.Direction.BottomToTop, true); RectTransform vScrollbarRT = scrollbar.GetComponent <RectTransform>(); vScrollbarRT.anchorMin = Vector2.right; vScrollbarRT.anchorMax = Vector2.one; vScrollbarRT.pivot = Vector2.one; vScrollbarRT.sizeDelta = new Vector2(vScrollbarRT.sizeDelta.x, 0); // Setup item UI components. TextExpand itemLabelText = itemLabel.AddComponent <TextExpand>(); itemLabelText.alignment = TextAnchor.MiddleLeft; itemLabelText.color = Color.black; ImageExpand itemBackgroundImage = itemBackground.AddComponent <ImageExpand>(); itemBackgroundImage.color = new Color32(245, 245, 245, 255); ImageExpand itemCheckmarkImage = itemCheckmark.AddComponent <ImageExpand>(); itemCheckmarkImage.sprite = AssetDatabase.GetBuiltinExtraResource <Sprite>(kCheckmarkPath); ToggleExpand itemToggle = item.AddComponent <ToggleExpand>(); itemToggle.targetGraphic = itemBackgroundImage; itemToggle.graphic = itemCheckmarkImage; itemToggle.isOn = true; // Setup template UI components. ImageExpand templateImage = template.AddComponent <ImageExpand>(); templateImage.sprite = AssetDatabase.GetBuiltinExtraResource <Sprite>(kStandardSpritePath); templateImage.type = Image.Type.Sliced; ScrollRect templateScrollRect = template.AddComponent <ScrollRect>(); templateScrollRect.content = (RectTransform)content.transform; templateScrollRect.viewport = (RectTransform)viewport.transform; templateScrollRect.horizontal = false; templateScrollRect.movementType = ScrollRect.MovementType.Clamped; templateScrollRect.verticalScrollbar = scrollbarScrollbar; templateScrollRect.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport; templateScrollRect.verticalScrollbarSpacing = -3; Mask scrollRectMask = viewport.AddComponent <Mask>(); scrollRectMask.showMaskGraphic = false; ImageExpand viewportImage = viewport.AddComponent <ImageExpand>(); viewportImage.sprite = AssetDatabase.GetBuiltinExtraResource <Sprite>("UI/Skin/UIMask.psd"); viewportImage.type = Image.Type.Sliced; // Setup dropdown UI components. TextExpand labelText = label.AddComponent <TextExpand>(); labelText.text = "Option A"; labelText.alignment = TextAnchor.MiddleLeft; ImageExpand arrowImage = arrow.AddComponent <ImageExpand>(); arrowImage.sprite = AssetDatabase.GetBuiltinExtraResource <Sprite>("UI/Skin/DropdownArrow.psd");//UI/Skin/DropdownArrow.psd ImageExpand backgroundImage = root.AddComponent <ImageExpand>(); backgroundImage.sprite = AssetDatabase.GetBuiltinExtraResource <Sprite>(kStandardSpritePath); backgroundImage.color = whiteColor; backgroundImage.type = Image.Type.Sliced; DropDownExpand dropdown = root.AddComponent <DropDownExpand>(); dropdown.targetGraphic = backgroundImage; ColorBlock colors = dropdown.colors; colors.highlightedColor = new Color(0.882f, 0.882f, 0.882f); colors.pressedColor = new Color(0.698f, 0.698f, 0.698f); colors.disabledColor = new Color(0.521f, 0.521f, 0.521f); dropdown.template = template.GetComponent <RectTransform>(); dropdown.captionText = labelText; dropdown.itemText = itemLabelText; // Setting default Item list. //itemLabelText.text = "Option A"; // Set up RectTransforms. RectTransform labelRT = label.GetComponent <RectTransform>(); labelRT.anchorMin = Vector2.zero; labelRT.anchorMax = Vector2.one; labelRT.offsetMin = new Vector2(10, 6); labelRT.offsetMax = new Vector2(-25, -7); RectTransform arrowRT = arrow.GetComponent <RectTransform>(); arrowRT.anchorMin = new Vector2(1, 0.5f); arrowRT.anchorMax = new Vector2(1, 0.5f); arrowRT.sizeDelta = new Vector2(20, 20); arrowRT.anchoredPosition = new Vector2(-15, 0); RectTransform templateRT = template.GetComponent <RectTransform>(); templateRT.anchorMin = new Vector2(0, 0); templateRT.anchorMax = new Vector2(1, 0); templateRT.pivot = new Vector2(0.5f, 1); templateRT.anchoredPosition = new Vector2(0, 2); templateRT.sizeDelta = new Vector2(0, 150); RectTransform viewportRT = viewport.GetComponent <RectTransform>(); viewportRT.anchorMin = new Vector2(0, 0); viewportRT.anchorMax = new Vector2(1, 1); viewportRT.sizeDelta = new Vector2(-18, 0); viewportRT.pivot = new Vector2(0, 1); RectTransform contentRT = content.GetComponent <RectTransform>(); contentRT.anchorMin = new Vector2(0f, 1); contentRT.anchorMax = new Vector2(1f, 1); contentRT.pivot = new Vector2(0.5f, 1); contentRT.anchoredPosition = new Vector2(0, 0); contentRT.sizeDelta = new Vector2(0, 28); RectTransform itemRT = item.GetComponent <RectTransform>(); itemRT.anchorMin = new Vector2(0, 0.5f); itemRT.anchorMax = new Vector2(1, 0.5f); itemRT.sizeDelta = new Vector2(0, 20); RectTransform itemBackgroundRT = itemBackground.GetComponent <RectTransform>(); itemBackgroundRT.anchorMin = Vector2.zero; itemBackgroundRT.anchorMax = Vector2.one; itemBackgroundRT.sizeDelta = Vector2.zero; RectTransform itemCheckmarkRT = itemCheckmark.GetComponent <RectTransform>(); itemCheckmarkRT.anchorMin = new Vector2(0, 0.5f); itemCheckmarkRT.anchorMax = new Vector2(0, 0.5f); itemCheckmarkRT.sizeDelta = new Vector2(20, 20); itemCheckmarkRT.anchoredPosition = new Vector2(10, 0); RectTransform itemLabelRT = itemLabel.GetComponent <RectTransform>(); itemLabelRT.anchorMin = Vector2.zero; itemLabelRT.anchorMax = Vector2.one; itemLabelRT.offsetMin = new Vector2(20, 1); itemLabelRT.offsetMax = new Vector2(-10, -2); template.SetActive(false); //ClearRays(dropdown); }