protected override void Start() { contentFitter = GetComponentInChildren <ContentSizeFitter>(); chatScrollArea = transform.parent.gameObject.GetComponent <ScrollRect>(); onValueChanged.AddListener(new UnityEngine.Events.UnityAction <string>(ResizeInput)); }
private void DrawLabel(string labelName, string labelValue, float labelPosition, bool isOnXAxis) { GameObject label = FindChild(labelName); if (label == null) { label = new GameObject(labelName); label.transform.SetParent(FindChild("LabelsContainer").transform); label.AddComponent <RectTransform>(); Text labelTextTmp = label.AddComponent <Text>(); labelTextTmp.alignment = TextAnchor.MiddleCenter; label.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1); ContentSizeFitter labelCSF = label.AddComponent <ContentSizeFitter>(); labelCSF.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; labelCSF.verticalFit = ContentSizeFitter.FitMode.PreferredSize; } Text labelText = label.GetComponent <Text>(); labelText.text = labelValue; labelText.color = labelsFontColor; labelText.fontSize = labelsFontSize; labelText.font = labelsFont != null ? labelsFont : Resources.GetBuiltinResource <Font>("Arial.ttf"); UpdateLabelPosition(label, labelPosition, isOnXAxis); }
public static void CallBack(this ContentSizeFitter contentSizeFitter, System.Action <Vector2> change) { ContentSizeFitterEvent test = contentSizeFitter.GetComponent <ContentSizeFitterEvent>() ?? contentSizeFitter.gameObject.AddComponent <ContentSizeFitterEvent>(); test.change = change; }
private void CreatText(string content = "") { GameObject go = new GameObject(); go.AddComponent <CanvasRenderer>(); go.transform.SetParent(container_content); go.transform.localScale = Vector3.one; go.transform.localPosition = new Vector3(0, -containerHeight, 0); go.name = "txt_msg"; Text txt = go.AddComponent <Text>(); txt.supportRichText = true; txt.fontSize = 30; txt.text = (content != "") ? content : "<color=yellow>[hero1]:</color><color=red>代码生成出来的代码生成出来的代码生成出来的代码生成出来的代码生成出来的代码生成出来的代码生成出来的代码生成出来的的</color>" + index.ToString();; txt.font = Resources.GetBuiltinResource <Font>("Arial.ttf"); RectTransform rt = go.transform as RectTransform; rt.pivot = new Vector2(0, 1); rt.anchorMin = rt.anchorMax = new Vector2(0, 1); rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 100); rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 850); ContentSizeFitter contentSizeFitter = go.AddComponent <ContentSizeFitter>(); contentSizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; //Debug.Log("文本框大小: " + txt.preferredHeight + " 。 " + txt.preferredWidth); }
private void CreatePanel(Transform parent) { _panel = new GameObject("TwoColumnPanel", typeof(RectTransform)); _panel.transform.SetParent(parent, worldPositionStays: false); RectTransform transform = _panel.GetComponent <RectTransform>(); transform.anchorMin = new Vector2(1, 0); transform.anchorMax = new Vector2(1, 0); transform.pivot = Vector2.zero; transform.anchoredPosition = Vector2.zero; HorizontalLayoutGroup panelLayout = _panel.AddComponent <HorizontalLayoutGroup>(); panelLayout.padding = new RectOffset(left: 5, right: 5, top: 5, bottom: 5); panelLayout.spacing = 8f; ContentSizeFitter panelFitter = _panel.AddComponent <ContentSizeFitter>(); panelFitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; panelFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; Image panelImage = _panel.AddComponent <Image>(); panelImage.color = _color; _leftColumn = new GameObject("LeftColumn", typeof(RectTransform)); _leftColumn.transform.SetParent(_panel.transform, worldPositionStays: false); VerticalLayoutGroup leftLayout = _leftColumn.AddComponent <VerticalLayoutGroup>(); leftLayout.childControlWidth = true; leftLayout.childControlHeight = true; leftLayout.childForceExpandWidth = true; leftLayout.childForceExpandHeight = false; leftLayout.childAlignment = TextAnchor.LowerLeft; leftLayout.spacing = 5f; ContentSizeFitter leftFitter = _leftColumn.AddComponent <ContentSizeFitter>(); leftFitter.horizontalFit = ContentSizeFitter.FitMode.Unconstrained; leftFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; _rightColumn = new GameObject("RightColumn", typeof(RectTransform)); _rightColumn.transform.SetParent(_panel.transform, worldPositionStays: false); VerticalLayoutGroup rightLayout = _rightColumn.AddComponent <VerticalLayoutGroup>(); rightLayout.childControlWidth = true; rightLayout.childControlHeight = true; rightLayout.childForceExpandWidth = true; rightLayout.childForceExpandHeight = false; rightLayout.childAlignment = TextAnchor.LowerRight; rightLayout.spacing = 5f; ContentSizeFitter rightFitter = _rightColumn.AddComponent <ContentSizeFitter>(); rightFitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; rightFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; }
public IEnumerator CaretRectSameSizeAsTextRect() { InputField inputfield = m_PrefabRoot.GetComponentInChildren <InputField>(); HorizontalLayoutGroup lg = inputfield.gameObject.AddComponent <HorizontalLayoutGroup>(); lg.childControlWidth = true; lg.childControlHeight = false; lg.childForceExpandWidth = true; lg.childForceExpandHeight = true; ContentSizeFitter csf = inputfield.gameObject.AddComponent <ContentSizeFitter>(); csf.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; csf.verticalFit = ContentSizeFitter.FitMode.Unconstrained; inputfield.text = "Hello World!"; yield return(new WaitForSeconds(1.0f)); Rect prevTextRect = inputfield.textComponent.rectTransform.rect; Rect prevCaretRect = (inputfield.textComponent.transform.parent.GetChild(0) as RectTransform).rect; inputfield.text = "Hello World!Hello World!Hello World!"; LayoutRebuilder.MarkLayoutForRebuild(inputfield.transform as RectTransform); yield return(new WaitForSeconds(1.0f)); Rect newTextRect = inputfield.textComponent.rectTransform.rect; Rect newCaretRect = (inputfield.textComponent.transform.parent.GetChild(0) as RectTransform).rect; Assert.IsFalse(prevTextRect == newTextRect); Assert.IsTrue(prevTextRect == prevCaretRect); Assert.IsFalse(prevCaretRect == newCaretRect); Assert.IsTrue(newTextRect == newCaretRect); }
internal Selector( GameObject gameObject, HC.ReactorId pieceId, RectTransform rectTransform, CanvasRenderer canvasRenderer, ScrollRect scrollRect, RectMask2D rectMask2, GridLayoutGroup gridLayout, ContentSizeFitter contentSize, Image vScrollbarImage, Scrollbar vScrollbar, Image vScrollbarHandleImage, Image hScrollbarImage, Scrollbar hScrollbar, Image hScrollbarHandleImage ) : base(gameObject, pieceId, rectTransform, canvasRenderer) { this.scrollRect = scrollRect; this.rectMask2 = rectMask2; this.gridLayout = gridLayout; this.contentSize = contentSize; this.vScrollbarImage = vScrollbarImage; this.vScrollbar = vScrollbar; this.vScrollbarHandleImage = vScrollbarHandleImage; this.hScrollbarImage = hScrollbarImage; this.hScrollbar = hScrollbar; this.hScrollbarHandleImage = hScrollbarHandleImage; }
public CTooltip(CToolkitUI Toolkit, CGameUIStyle Style, GameObject Root) { _ui = Toolkit; _style = Style; _tooltipOverGame = false; _tooltip = _ui.CreateElement(Root, "tooltip"); _ui.AddImage(_tooltip, _style.TooltipBackground); _ui.SetTransform(_tooltip, 0, 0, 256, 256); _ui.AddVerticalLayout(_tooltip, new RectOffset(3, 3, 3, 3), 3); _tooltip.GetComponent <RectTransform>().anchorMax = new Vector2(0, 0); _tooltip.GetComponent <RectTransform>().anchorMin = new Vector2(0, 0); ContentSizeFitter fitter = _tooltip.AddComponent <ContentSizeFitter>(); fitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; fitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; float width = 150.0f; GameObject title = _ui.CreateTextElement(_tooltip, "Title", "title", CToolkitUI.ETextStyle.TS_HEADING); _ui.AddLayout(title, width, -1, -1, -1); GameObject details = _ui.CreateTextElement(_tooltip, "Sub-title", "subtitle", CToolkitUI.ETextStyle.TS_DEFAULT); _ui.AddLayout(details, width, -1, -1, -1); GameObject desc = _ui.CreateTextElement(_tooltip, "Description text that can be longer.", "description", CToolkitUI.ETextStyle.TS_HEADING); _ui.AddLayout(desc, width, -1, -1, -1); Hide(false); }
public void Init() { if (GetComponent <ScrollRect>() != null) { _scrollRect = GetComponent <ScrollRect>(); _scrollRect.onValueChanged.AddListener(OnScroll); _isHorizontal = _scrollRect.horizontal; _isVertical = _scrollRect.vertical; for (int i = 0; i < _scrollRect.content.childCount; i++) { items.Add(_scrollRect.content.GetChild(i).GetComponent <RectTransform>()); } if (_scrollRect.content.GetComponent <VerticalLayoutGroup>() != null) { _verticalLayoutGroup = _scrollRect.content.GetComponent <VerticalLayoutGroup>(); } if (_scrollRect.content.GetComponent <HorizontalLayoutGroup>() != null) { _horizontalLayoutGroup = _scrollRect.content.GetComponent <HorizontalLayoutGroup>(); } if (_scrollRect.content.GetComponent <GridLayoutGroup>() != null) { _gridLayoutGroup = _scrollRect.content.GetComponent <GridLayoutGroup>(); } if (_scrollRect.content.GetComponent <ContentSizeFitter>() != null) { _contentSizeFitter = _scrollRect.content.GetComponent <ContentSizeFitter>(); } } else { Debug.LogError("UI_ScrollRectOcclusion => No ScrollRect component found"); } }
void MakeHolder() { if (entryHolder != null) { Destroy(entryHolder); } entryHolder = new GameObject("Entry Holder"); entryHolder.transform.SetParent(holder.transform, false); // Add RectTransform and stretch it to the parent RectTransform entryHolderRect = entryHolder.AddComponent <RectTransform>(); entryHolderRect.anchorMin = new Vector2(0.0f, 0.0f); entryHolderRect.anchorMax = new Vector2(1.0f, 1.0f); entryHolderRect.pivot = new Vector2(0.5f, 0.5f); entryHolderRect.offsetMin = new Vector2(0.0f, 0.0f); entryHolderRect.offsetMax = new Vector2(0.0f, 0.0f); // Add VerticalLayoutGroup so our dynamic elements are all neatly ordered VerticalLayoutGroup group = entryHolder.AddComponent <VerticalLayoutGroup>(); group.childForceExpandHeight = false; group.childControlHeight = false; group.childControlWidth = false; // Add the ContentSizeFitter ContentSizeFitter fitter = entryHolder.AddComponent <ContentSizeFitter>(); fitter.verticalFit = ContentSizeFitter.FitMode.MinSize; ScrollRect scroll = holder.transform.parent.GetComponent <ScrollRect>(); scroll.content = entryHolderRect; }
protected override void Awake() { m_Button = GetComponent <Button>(); m_ContentSizeFitter = GetComponent <ContentSizeFitter>(); if (transform.childCount > 0) { Text text = GetComponentInChildren <Text>(); if (text == null) { m_ButtonText = text.GetComponent <SudokuText>(); if (m_ButtonText == null) { m_ButtonText = transform.GetChild(0).gameObject.AddComponent <SudokuText>(); } } else { m_ButtonText = text.gameObject.AddComponent <SudokuText>(); } } else { GameObject textGo = new GameObject(); textGo.transform.parent = transform; m_ButtonText = textGo.AddComponent <SudokuText>(); } base.Awake(); }
// Use this for initialization IEnumerator Start() { contentSizeFitter = content.GetComponent <ContentSizeFitter>(); verticalLayoutGroup = content.GetComponent <VerticalLayoutGroup>(); Button _button; for (int i = 0, imax = listData.Count; i < imax; i++) { int _idx = i; _button = Instantiate(prefabButton) as Button; _button.onClick.AddListener(() => { Invoke_Message(listData[_idx]); }); _button.GetComponentInChildren <Text>().text = listData[_idx].name; _button.transform.SetParent(content); } //DestroyImmediate(prefabButton.gameObject); prefabButton.gameObject.SetActive(false); contentSizeFitter.enabled = true; verticalLayoutGroup.enabled = true; yield return(null); contentSizeFitter.enabled = false; verticalLayoutGroup.enabled = false; }
private void SetItem(Item item, Item otherItem, Transform ItemDiscription, Transform ItemStats) { foreach (Transform child in ItemStats) { Destroy(child.gameObject); } if (item != null) { foreach (var stat in item.stats) { GameObject obj = new GameObject(stat.Key.ToString()); obj.transform.parent = ItemStats; obj.AddComponent <HorizontalLayoutGroup>(); string statName = stat.Key.ToString(); statName.Replace('_', ' '); AddText(obj, statName, Color.white); AddText(obj, ": ", Color.white); AddText(obj, stat.Value.ToString(), Color.white); int otherItemStat = otherItem?.stats.ContainsKey(stat.Key) ?? false ? otherItem.stats[stat.Key] : 0; int delta = stat.Value - otherItemStat; if (delta != 0) { AddText(obj, " " + (delta > 0 ? "+" : "") + delta, delta > 0 ? Color.green : (delta < 0 ? Color.red : Color.white)); } ContentSizeFitter fit = obj.AddComponent <ContentSizeFitter>(); fit.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; fit.verticalFit = ContentSizeFitter.FitMode.PreferredSize; } } }
private void Awake() { _grandParent = transform.parent.parent; _panelDice = FindObjectOfType <UI_Panel_Dice>(); verticalLayoutGroup = GetComponentInParent <VerticalLayoutGroup>(); contentSizeFitter = _grandParent.GetComponent <ContentSizeFitter>(); }
/// <summary> /// Create UITree Component /// </summary> public static GameObject CreateUITree(Resources resources) { //create ui tree GameObject uiTree = DefaultControls.CreateScrollView(convertToDefaultResources(resources)); uiTree.AddComponent <UITree>(); ScrollRect uiTreeScrollRect = uiTree.GetComponent <ScrollRect>(); uiTree.GetComponent <RectTransform>().sizeDelta = _defaultUITreeSize; uiTreeScrollRect.horizontal = false; uiTree.name = "UITree"; Transform content = uiTree.transform.Find("Viewport/Content"); GridLayoutGroup glg = content.gameObject.AddComponent <GridLayoutGroup>(); glg.cellSize = _defaultUITreeNodeSize; glg.spacing = new Vector2(0, 2); glg.constraint = GridLayoutGroup.Constraint.FixedColumnCount; glg.constraintCount = 1; ContentSizeFitter csf = content.gameObject.AddComponent <ContentSizeFitter>(); csf.verticalFit = ContentSizeFitter.FitMode.PreferredSize; //create root node GameObject rootNode = CreateUITreeNode(resources); SetParentAndAlign(rootNode, content); return(uiTree); }
private void SetSysInfo(GameObject sysobj, string sys_mes) { GameObject txtobj = sysobj.transform.Find("mes").gameObject; txtobj.GetComponentDefault <Chathyperlink>().gettxt = sys_mes; Chathyperlink Pic = txtobj.GetComponentDefault <Chathyperlink>(); Pic.gameObject.SetActive(true); Pic.text = sys_mes; Pic.Set(); Pic.text = Pic.gettxt; float width = Pic.preferredWidth; float height = Pic.preferredHeight; RectTransform sysobj_height = sysobj.GetComponent <RectTransform>(); if (width <= 423f) { sysobj_height.sizeDelta = new Vector2(sysobj_height.sizeDelta.x, 33f);//设置图片的宽高 } else { ContentSizeFitter a = Pic.gameObject.GetComponent <ContentSizeFitter>(); a.horizontalFit = ContentSizeFitter.FitMode.Unconstrained; sysobj_height.sizeDelta = new Vector2(sysobj_height.sizeDelta.x, height + 8f);//设置图片的宽高 } SetPostion(sysobj); }
private void CreateSpawnUI() { spawnUI = new GameObject(); spawnUI.name = "Spawn Inventory UI"; spawnUI.layer = LayerMask.NameToLayer("UI"); Canvas canvas = GameObject.Find("Canvas").GetComponent <Canvas>(); spawnUI.transform.SetParent(canvas.transform, false); RectTransform rectTransform = spawnUI.AddComponent <RectTransform>(); rectTransform.pivot = new Vector2(0, 0.5f); rectTransform.anchorMin = new Vector2(0, 0.5f); rectTransform.anchorMax = new Vector2(0, 0.5f); rectTransform.anchoredPosition = new Vector2(0, 0); spawnUI.AddComponent <Image>(); VerticalLayoutGroup vlg = spawnUI.AddComponent <VerticalLayoutGroup>(); vlg.childForceExpandWidth = false; vlg.childForceExpandHeight = false; vlg.spacing = 0; ContentSizeFitter csf = spawnUI.AddComponent <ContentSizeFitter>(); csf.horizontalFit = ContentSizeFitter.FitMode.MinSize; csf.verticalFit = ContentSizeFitter.FitMode.MinSize; }
public static GameObject CreateLabel(float x, float y, string text_to_print, int font_size, Color text_color, Transform parent) { GameObject UItextGO = new GameObject(text_to_print); UItextGO.transform.SetParent(parent); RectTransform trans = UItextGO.AddComponent <RectTransform>(); trans.anchoredPosition = new Vector2(x, y); Text text = UItextGO.AddComponent <Text>(); text.text = text_to_print; text.font = Font.CreateDynamicFontFromOSFont("Arial", font_size); text.fontSize = font_size; text.color = text_color; text.alignment = TextAnchor.MiddleCenter; ContentSizeFitter fitter = UItextGO.AddComponent <ContentSizeFitter>(); fitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; fitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; return(UItextGO); }
public void Initialize(int columnIndex) { transform.DestroyChildrenImmediate(); cellContainers.Clear(); this.columnIndex = columnIndex; if (table.horizontal) { columnLayout = gameObject.GetOrAddComponent <HorizontalLayoutGroup>(); } else { columnLayout = gameObject.GetOrAddComponent <VerticalLayoutGroup>(); } columnLayout.childControlWidth = true; columnLayout.childControlHeight = true; columnLayout.childForceExpandWidth = true; columnLayout.childForceExpandHeight = true; columnLayout.spacing = -1f; ContentSizeFitter sizeFitter = gameObject.AddComponent <ContentSizeFitter>(); sizeFitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; sizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; layoutElement = gameObject.AddComponent <LayoutElement>(); if (table.hasTitles) { CreateTitleCell(); } CreateCells(); Update(); }
public void StartUpdatingSize(GameObject pChild) { _childRect = pChild.GetComponent <RectTransform>(); _rect = GetComponent <RectTransform>(); _contentSizeFitter = transform.parent.GetComponent <ContentSizeFitter>(); StartCoroutine(updateSizeWhileAnimationIsRunning(pChild)); }
public void TearDown() { m_PrefabRoot = null; m_ContentSizeFitter = null; m_RectTransform = null; GameObject.DestroyImmediate(m_PrefabRoot); }
private void Awake() { //pre-allocate this space consoleOutputObjects = new Queue <Text>(MAX_ENTRIES); Debug.Assert(consoleOutputPrefab != null); Debug.Assert(scrollrect != null); Debug.Assert(consoleAutocomplete != null); Debug.Assert(consoleCanvas != null); Debug.Assert(inputField != null); contentFrameVLG = scrollrect.content.GetComponent <VerticalLayoutGroup>(); contentFrameCSF = scrollrect.content.GetComponent <ContentSizeFitter>(); Debug.Assert(contentFrameVLG != null); Debug.Assert(contentFrameCSF != null); //Need to make sure the prefab has this object Debug.Assert(consoleOutputPrefab.GetComponent <ContentSizeFitter>() != null); sInstance = this; forwardToUnityDebug = true; scrollrect.verticalNormalizedPosition = 0; Log("Console online!"); SetConsoleActive(false); consoleActivationEvent = null; }
private void CreateGridElement(Project project) { // image projet GameObject go = new GameObject(project.Name); Image img = go.AddComponent <Image>() as Image; LoadProjectHandler loadProjectHandler = go.AddComponent <LoadProjectHandler>(); loadProjectHandler.SetProject(project); img.type = Image.Type.Sliced; go.SetActive(true); go.transform.SetParent(projectGrid.transform); // img.sprite = Sprite.Create(image, new Rect(0, 0, image.width, image.height), new Vector2(0.5f, 0.5f)); img.sprite = Resources.Load <Sprite>("ville"); //titre projet GameObject title = new GameObject(project.Name + "-Title"); Text TitleProject = title.AddComponent <Text>() as Text; title.transform.SetParent(go.transform); TitleProject.text = project.Name; TitleProject.color = Color.black; TitleProject.fontSize = 20; TitleProject.font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; ContentSizeFitter csf = title.AddComponent <ContentSizeFitter>(); csf.verticalFit = ContentSizeFitter.FitMode.PreferredSize; csf.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; title.SetActive(true); title.transform.position += new Vector3(0, -LayoutUtility.GetPreferredHeight(TitleProject.rectTransform) - 50); }
// Use this for initialization void Start() { m_text = GetComponent <Text>(); content = GetComponent <ContentSizeFitter>(); word(); Debug.Log(m_text.preferredWidth); }
protected override void Start() { contentFitter = GetComponentInChildren <ContentSizeFitter>(); chatScrollArea = transform.parent.gameObject.GetComponent <ScrollRect>(); onValueChanged.AddListener(ResizeInput); }
public void AddCustomDebugToolItem(string text, GameHandler callbackHandler) { GameObject newGo = GameCloneUtils.CreateEmptyUIObjectWithParent(DebugToolsItemHost.transform, "DebugToolItem"); RectTransform rectTransform = newGo.GetComponent <RectTransform>(); rectTransform.pivot = new Vector2(0, 1); UIAnchorPosUtils.SetUIAnchor(rectTransform, UIAnchor.Stretch, UIAnchor.Top); CustomData customData = newGo.AddComponent <CustomData> (); customData.customData = callbackHandler; Text newText = newGo.AddComponent <Text>(); newText.font = Resources.GetBuiltinResource <Font>("Arial.ttf"); newText.text = text; newText.color = Color.white; newText.fontSize = 11; newText.alignment = TextAnchor.MiddleCenter; ContentSizeFitter contentSizeFitter = newGo.AddComponent <ContentSizeFitter>(); contentSizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; EventTriggerListener.Get(newGo).onClick = OnCustomDebugToolItemClick; rectTransform.anchoredPosition = new Vector2(rectTransform.anchoredPosition.x, -customDebugToolItemY); customDebugToolItemY += 20; DebugToolsItemHost.sizeDelta = new Vector2(DebugToolsItemHost.sizeDelta.x, customDebugToolItemY); }
protected GameObject getCacheImage() { GameObject ret = null; int len = _cacheImg.Count; for (int i = 0; i < len; i++) { LCacheElement cacheElem = _cacheImg[i]; if (cacheElem.isUse == false) { cacheElem.isUse = true; ret = cacheElem.node; break; } } if (ret == null) { ret = new GameObject(); ret.AddComponent <Image>(); ContentSizeFitter fit = ret.AddComponent <ContentSizeFitter>(); fit.verticalFit = ContentSizeFitter.FitMode.PreferredSize; fit.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; RectTransform rtran = ret.GetComponent <RectTransform>(); rtran.pivot = Vector2.zero; rtran.anchorMax = new Vector2(0, 0); rtran.anchorMin = new Vector2(0, 0); LCacheElement cacheElem = new LCacheElement(ret); cacheElem.isUse = true; _cacheImg.Add(cacheElem); } return(ret); }
// Token: 0x06001130 RID: 4400 RVA: 0x00070DD4 File Offset: 0x0006F1D4 public HierarchyWindow() { base.gameObject.name = "Hierarchy"; base.tab.label.translation = new TranslatedText(new TranslationReference("SDG", "Devkit.Window.Hierarchy.Title")); base.tab.label.translation.format(); this.itemsView = new Sleek2Scrollview(); this.itemsView.transform.reset(); this.itemsView.transform.offsetMin = new Vector2(5f, 5f); this.itemsView.transform.offsetMax = new Vector2(-5f, -5f); this.itemsView.vertical = true; this.itemsPanel = new Sleek2Element(); this.itemsPanel.name = "Panel"; VerticalLayoutGroup verticalLayoutGroup = this.itemsPanel.gameObject.AddComponent <VerticalLayoutGroup>(); verticalLayoutGroup.spacing = 5f; verticalLayoutGroup.childControlHeight = false; verticalLayoutGroup.childForceExpandHeight = false; ContentSizeFitter contentSizeFitter = this.itemsPanel.gameObject.AddComponent <ContentSizeFitter>(); contentSizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; this.itemsPanel.transform.reset(); this.itemsPanel.transform.pivot = new Vector2(0f, 1f); this.itemsView.panel = this.itemsPanel; this.addElement(this.itemsView); LevelHierarchy.itemAdded += this.handleItemAdded; LevelHierarchy.itemRemoved += this.handleItemRemoved; LevelHierarchy.loaded += this.handleLoaded; this.refresh(); }
/// <summary> /// 更新大小显示 /// </summary> /// <param name="contentSizeFitter"></param> /// <returns></returns> IEnumerator UpdateContentSizeFitter(ContentSizeFitter contentSizeFitter) { contentSizeFitter.enabled = false; yield return(null); contentSizeFitter.enabled = true; }
public override void GameSetting() { for (int i = 0; i < m_Buttons.Length; i++) { m_ButtonDic.Add(m_Buttons[i].name, m_Buttons[i].gameObject); string btnName = m_Buttons[i].name; m_Buttons[i].onClick.AddListener(() => MenuButtonClick(btnName)); } //m_ButtonBaseSize = m_Buttons[0].image.rectTransform.sizeDelta; m_ContentSizeFitter = m_MenuBoard.GetComponent <ContentSizeFitter>(); m_MenuTypeDic.Add(MenuType.TileMenu, m_TileMenu); m_MenuTypeDic.Add(MenuType.PlayerShopMenu, m_PlayerShopMenu); m_MenuTypeDic.Add(MenuType.PlayerStandShopMenu, m_PlayerStandShopMenu); m_MenuTypeDic.Add(MenuType.PlayerDeadMenu, m_PlayerDeadMenu); m_MenuTypeDic.Add(MenuType.PlayerMoveCanAtkMenu, m_PlayerMoveCanAtkMenu); //for (MenuType i = MenuType.START + 1; i < MenuType.MAX; i++) //{ // MenuType menuType = i; // string[] temp = (string[])GetType().GetField("m_" + i.ToString()).GetValue(this); // if (temp != null) // { // m_MenuTypeDic.Add(menuType, temp); // } //} m_UIBlockImage = m_UIBlock.GetComponent <Image>(); //m_UIBlock.onClick.AddListener(UIBlockClick); m_UIBlock.SetPointEvent(UIBlockClick); UIBlockSwitch(false); SetMsgShow(false); m_TileMask = LayerMask.GetMask("Tile"); m_ButtonCOnfirmYes.onClick.AddListener(ConfirmYesClick); m_ButtonCOnfirmNo.onClick.AddListener(ConfirmNoClick); }