public static GameObject CreateLoopHorizontalScrollRect() { GameObject root = CreateUIElementRoot("Loop Horizontal Scroll Rect", new Vector2(200, 200)); GameObject viewpoint = CreateUIObject("ViewPoint", root); GameObject content = CreateUIObject("Content", viewpoint); RectTransform contentRT = content.GetComponent <RectTransform>(); contentRT.anchorMin = new Vector2(0, 0.5f); contentRT.anchorMax = new Vector2(0, 0.5f); contentRT.sizeDelta = new Vector2(0, 200); contentRT.pivot = new Vector2(0, 0.5f); // Setup UI components. LoopHorizontalScrollRect scrollRect = root.AddComponent <LoopHorizontalScrollRect>(); scrollRect.content = contentRT; scrollRect.viewport = null; scrollRect.horizontalScrollbar = null; scrollRect.verticalScrollbar = null; scrollRect.horizontal = true; scrollRect.vertical = false; scrollRect.horizontalScrollbarVisibility = LoopScrollRect.ScrollbarVisibility.Permanent; scrollRect.verticalScrollbarVisibility = LoopScrollRect.ScrollbarVisibility.Permanent; scrollRect.horizontalScrollbarSpacing = 0; scrollRect.verticalScrollbarSpacing = 0; root.AddComponent <UILoopScrollView>(); RectTransform viewpointRt = viewpoint.GetComponent <RectTransform>(); viewpointRt.anchorMin = new Vector2(0, 0); viewpointRt.anchorMax = new Vector2(1, 1); viewpointRt.sizeDelta = new Vector2(0, 0); viewpointRt.pivot = new Vector2(0.5f, 0.5f); viewpoint.AddComponent <Mask>(); Image image = viewpoint.AddComponent <Image>(); Color c = image.color; c.a = 1.0f / 255; image.color = c; HorizontalLayoutGroup layoutGroup = content.AddComponent <HorizontalLayoutGroup>(); layoutGroup.childAlignment = TextAnchor.MiddleLeft; layoutGroup.childForceExpandWidth = false; layoutGroup.childForceExpandHeight = true; ContentSizeFitter sizeFitter = content.AddComponent <ContentSizeFitter>(); sizeFitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; sizeFitter.verticalFit = ContentSizeFitter.FitMode.Unconstrained; return(root); }
private void Awake() { _bottom = transform.Find("Bottom"); normalPosY = _bottom.localPosition.y; _imageList = _bottom.Find("BottomSelect/Image/Scroll View").GetComponent <LoopHorizontalScrollRect>(); _imageList.prefabName = "LoveDiary/Prefabs/Items/LoveDiaryEditImageItem"; _imageList.poolSize = 6; _imageList.UpdateCallback = ImageListUpdateCallback; _labelList = transform.Find("LabelSelect/Scroll View").GetComponent <LoopVerticalScrollRect>(); _labelList.prefabName = "LoveDiary/Prefabs/Items/LoveDiaryEditLabelItem"; _labelList.poolSize = 12; _labelList.UpdateCallback = LabelListUpdateCallback; _saveBtn = transform.Find("SaveBtn").GetComponent <Button>(); _saveBtn.onClick.AddListener(SaveDiary); //string txt = show ? I18NManager.Get("Common_Save") : I18NManager.Get("Common_Compile"); _saveBtn.transform.Find("Text").GetComponent <Text>().text = I18NManager.Get("Common_Save"); _toggleGroupBottom = _bottom.Find("ToggleBottom"); _toggleSelectGroupBottom = _bottom.Find("BottomSelect"); _editContains = transform.Find("EditContains"); _okInputBtn = _bottom.Find("BottomSelect/Text/BigBtn").GetComponent <Button>(); _cancelInputBtn = _bottom.Find("BottomSelect/Text/SmallBtn").GetComponent <Button>(); _inputField = _bottom.Find("BottomSelect/Text/InputField").GetComponent <InputField>(); _okInputBtn.onClick.AddListener(Bigger); _cancelInputBtn.onClick.AddListener(Smaller); _inputField.onValueChanged.AddListener(InputFieldValueChange); transform.Find("Label/SelectBtn").GetComponent <Button>().onClick.AddListener(() => { if (_curLoveDiaryEditType == LoveDiaryEditType.Show) { return; } GameObject gb = transform.Find("LabelSelect").gameObject; gb.SetActive(!gb.activeSelf); }); _okSelectLabelBtn = transform.Find("LabelSelect/OkBtn").GetComponent <Button>(); _okSelectLabelBtn.onClick.AddListener(() => { transform.Find("LabelSelect").gameObject.SetActive(false); SetTitleLabel(); if (isGuide) { GuideManager.Show(); isGuide = false; } }); UIEventListener.Get(_editContains.gameObject).onClick = OnClickBg; // UIEventListener.Get(_bottom.Find("Bg").gameObject).onClick = OnClickBottomBg; }
private void Awake() { _giftname = transform.Find("Title/Text").GetText(); _giftDesc = transform.Find("DescBg/DescText").GetText(); _awardList = transform.Find("AwardItemList").GetComponent <LoopHorizontalScrollRect>(); _realPrice = transform.Find("Price/PriceText").GetText(); _oldPrice = transform.Find("Price/OriText").GetText(); _buyBtn = transform.Find("BuyBtn").GetButton(); _buyBtn.onClick.AddListener(BuyGift); _buyCount = transform.Find("BuyCounts").GetText(); _endtimetxt = transform.Find("EndTime").GetText(); _line = transform.Find("Price/Line").gameObject; _awardList.prefabName = "Shop/Prefab/MallWindow/GiftAwardItem"; _awardList.poolSize = 2; }
public static GameObject CreateLoopHorizontalScrollRect(DefaultControls.Resources resources) { GameObject root = CreateUIElementRoot("Loop Horizontal Scroll Rect", new Vector2(200, 200)); GameObject content = CreateUIObject("Content", root); RectTransform contentRT = content.GetComponent <RectTransform>(); contentRT.anchorMin = new Vector2(0, 0.5f); contentRT.anchorMax = new Vector2(0, 0.5f); contentRT.sizeDelta = new Vector2(0, 200); contentRT.pivot = new Vector2(0, 0.5f); // Setup UI components. LoopHorizontalScrollRect scrollRect = root.AddComponent <LoopHorizontalScrollRect>(); scrollRect.content = contentRT; scrollRect.viewport = null; scrollRect.horizontalScrollbar = null; scrollRect.verticalScrollbar = null; scrollRect.horizontal = true; scrollRect.vertical = false; scrollRect.horizontalScrollbarVisibility = LoopScrollRect.ScrollbarVisibility.Permanent; scrollRect.verticalScrollbarVisibility = LoopScrollRect.ScrollbarVisibility.Permanent; scrollRect.horizontalScrollbarSpacing = 0; scrollRect.verticalScrollbarSpacing = 0; root.AddComponent <RectMask2D>(); HorizontalLayoutGroup layoutGroup = content.AddComponent <HorizontalLayoutGroup>(); layoutGroup.childAlignment = TextAnchor.MiddleLeft; layoutGroup.childForceExpandWidth = false; layoutGroup.childForceExpandHeight = true; ContentSizeFitter sizeFitter = content.AddComponent <ContentSizeFitter>(); sizeFitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; sizeFitter.verticalFit = ContentSizeFitter.FitMode.Unconstrained; return(root); }
public BuyGiftAmountChoice buyView;//购买界面 void FindComponent() { //npcView back_btn = transform.Find("Top/Back_btn").GetComponent <Button>(); setPainting = transform.Find("NPCLive2D").GetComponent <RawImage>(); npc2Player = transform.Find("Top/npcInfo/AddValue").GetComponent <GiftAddValue>(); player2Npc = transform.Find("Top/playerInfo/AddValue").GetComponent <GiftAddValue>(); npcFavorableValue = transform.Find("Top/npcInfo/Num").GetComponent <Text>(); playerFavorableValue = transform.Find("Top/playerInfo/Num").GetComponent <Text>(); //心动值 cardiacValue = transform.Find("Top/CardiacValue/box/Text").GetComponent <Text>(); //约会按钮 intimateDating = transform.Find("Top/DateBtn").GetComponent <Button>(); DateText = intimateDating.transform.Find("Text").GetComponent <Text>(); giftList = transform.Find("Bottom/LoopGiftList").GetComponent <LoopHorizontalScrollRect>(); setAmount.act = GiveGifts; }
private void Awake() { playViewList = transform.Find("RandPlay").GetComponent <LoopHorizontalScrollRect>(); emojiViewList = transform.Find("Emoji/EmojiList").GetComponent <LoopHorizontalScrollRect>(); }