public static void Adjust(ScrollRect rect ) { ScrollViewAdjust com = rect.GetComponent<ScrollViewAdjust>() ; if(com != null) { GameObject.Destroy(com) ; com = null ; } if(rect.GetComponentInChildren<GridLayoutGroup>()!=null) { com = rect.gameObject.AddComponent<ScrollViewAdjust>() ; } else if(rect.GetComponentInChildren<VerticalLayoutGroup>()!=null) { com = rect.gameObject.AddComponent<ScrollViewVerticalAdjust>() ; } else if(rect.GetComponentInChildren<HorizontalLayoutGroup>()!=null) { com = rect.gameObject.AddComponent<ScrollViewHarizonAdjust>() ; } else { Debug.LogWarning("Cannot Auto adjust scrollview without layout !!! ") ; } }
public void OnConnect() { network.AsyncConnect("127.0.0.1", 25251); connectionText.text = "Connecting..."; outputScroll.GetComponentInChildren <Text>().text = "sdffsdfdsd"; outputScroll.GetComponentInChildren <Scrollbar>().enabled = true; }
//Pushes more entities into Scroll rect (UI list) void updateView() { //Used to handle unnecessary listener calls from scroll bar if (scroll.value != 0f) { return; } //Push 10 more entities into Scroll rect int countBefore = view.GetComponentInChildren <AppendProgramList>().GetShownCount(); for (int i = countBefore; i < programList.Count; ++i) { if (i == countBefore + 10) { break; } //Prefer finnish title but if missing, use swedish string title = (programList.ElementAt(i).fi == "" ? programList.ElementAt(i).sv : programList.ElementAt(i).fi); view.GetComponentInChildren <AppendProgramList>().AppendProgram(title); } //Update scroll value to a position where the list doesn't change when new entities are added int countAfter = view.GetComponentInChildren <AppendProgramList>().GetShownCount(); if (countAfter > 10) { scroll.value = 1 / (countAfter / 10); } }
public void OnConnect() { //network.AsyncConnect("192.168.0.43", 25251); network.AsyncConnect("galaxyenter.cloudapp.net", 25251); connectionText.text = "Connecting..."; outputScroll.GetComponentInChildren <Text>().text = "sdffsdfdsd"; outputScroll.GetComponentInChildren <Scrollbar>().enabled = true; }
private void Start() { // Limpar nome do selecionado, descrição do selecionado e esconder // icone em destaque pois não há seleção ainda NomeDoSelecionado.text = string.Empty; //DescricaoDoSelecionado.GetComponentInChildren<TextMeshProUGUI>().text = string.Empty; //iconeGrandeEmDestaque.enabled = false; //Setar a descrição expandida inicial var descricaoExpandida = TextoExpandido; descricaoExpandida.text = "Agora é hora escolher qual o perfil que a turma apresentará através das INTELIGÊNCIAS MÚLTIPLAS." + "\n\nCada opção traz duas inteligências múltiplas que estarão mais latentes na sua turma.\nImportante saber que o comportamento " + "dos seus alunos refletirão no resultado final do jogo de acordo com as suas próximas escolhas."; // Esconder botão confirmar até que uma escolha seja feita botaoConfirmar.gameObject.SetActive(false); // Toda vez que o grupo de botões disser que um novo botão foi // selecionado, a página irá atualizar o ícone grande em destaque, // o nome do botão selecionado e o ícone pequeno na lateral esquerda grupoDeIconesInteligencias.QuandoUmElementoForSelecionadoEvent += (iconeSelecionado) => { iconeGrandeEmDestaque.sprite = iconeSelecionado.SpriteGrande; iconeGrandeEmDestaque.enabled = true; NomeDoSelecionado.text = iconeSelecionado.Valor.Nome; // Atualizar descrição para o nível de ensino selecionado var textoDaDescricaoDoSelecionado = DescricaoDoSelecionado.GetComponentInChildren <TextMeshProUGUI>(); textoDaDescricaoDoSelecionado.text = iconeSelecionado.Valor.Descricao; // Retornar/resetar scrollbar para o topo var scrollbar = DescricaoDoSelecionado.GetComponentInChildren <Scrollbar>(); if (scrollbar) { scrollbar.value = 1; } //Atualizar texto dentro do popup de expansão descricaoExpandida.text = iconeSelecionado.Valor.Expansao; var spritePequeno = iconeSelecionado.ImageComponent.sprite; iconePequenoGuia.sprite = spritePequeno; botaoConfirmar.gameObject.SetActive(true); }; }
public void Init() { scrollRect = GetComponent <ScrollRect>(); content = scrollRect.GetComponentInChildren <VerticalLayoutGroup>(true); contentCache = transform.Find("Cache"); scrollRect.content = content.transform as RectTransform; }
void SetScrollPosition() { if (m_ScrollRect == null) { return; } LayoutGroup layoutGroup = m_ScrollRect.GetComponentInChildren <LayoutGroup>(); if (layoutGroup == null) { return; } float height = m_ScrollRect.viewport.rect.height; float contentHeight = m_ScrollRect.content.rect.height; if (contentHeight <= height) { // コンテンツよりスクロールエリアのほうが広いので、スクロールしなくてもすべて表示されている m_ScrollRect.verticalNormalizedPosition = 1; m_ScrollRect.vertical = false; return; } m_ScrollRect.vertical = true; }
public void Update() { /* Lorem Ipsum generator til host listen * if(hostList.GetComponentInChildren<Text>().text.Length < 10000) * { * hostList.GetComponentInChildren<Text>().text += "\n" + LoremIpsum; * } */ try { //Debug.Log(NetworkServer.hostTopology.ToString()); //hostList.GetComponentInChildren<Text>().text for (int i = 0; i <= NetworkLobbyManager.singleton.matches.Count; i++) { hostList.GetComponentInChildren <Text>().text = NetworkLobbyManager.singleton.matches[i].name + "\t" + NetworkLobbyManager.singleton.matches[i].maxSize; } } catch { } }
private void UIPrep() { transform.position = article.GetComponent <Collider>().bounds.center; infoScroll.GetComponentInChildren <Text>().text = article.description; transform.Find("Canvas/AddToCartBtn/Price").GetComponent <Text>().text = article.price.ToString("F") + "€"; transform.Find("Canvas/Title/Text").GetComponent <Text>().text = article.articleName; }
private void Start() { // Limpar nome do selecionado, descrição do selecionado e esconder // icone em destaque pois não há seleção ainda NomeDoSelecionado.text = string.Empty; //Esconde descrição e ícone grande no início //DescricaoDoSelecionado.GetComponentInChildren<TextMeshProUGUI>().text = string.Empty; //iconeGrandeEmDestaque.enabled = false; //Setar a descrição expandida inicial var descricaoExpandida = TextoExpandido; descricaoExpandida.text = "Vamos iniciar o jogo escolhendo o NÍVEL DE ENSINO.\n\nTodo o planejamento e o melhor uso das mídias e metodologias " + "dependem em primeiro lugar da escolha do nível de ensino, já que as diferentes idades dos alunos estão atreladas aos estágios de aprendizagem " + "que podemos encontrar nesses níveis que você escolherá na próxima tela."; // Toda vez que o grupo de botões disser que um novo botão foi // selecionado, a página irá atualizar o ícone grande em destaque, // o nome do botão selecionado e o ícone pequeno na lateral esquerda grupoDeBotoes.QuandoUmNovoBotaoForSelecionadoEvent += (botaoSelecionado) => { iconeGrandeEmDestaque.sprite = botaoSelecionado.SpriteGrande; iconeGrandeEmDestaque.enabled = true; NomeDoSelecionado.text = botaoSelecionado.Valor.nome; // Atualizar descrição para o nível de ensino selecionado var textoDaDescricaoDoSelecionado = DescricaoDoSelecionado.GetComponentInChildren <TextMeshProUGUI>(); textoDaDescricaoDoSelecionado.text = botaoSelecionado.Valor.Descricao; // Retornar/resetar scrollbar para o topo var scrollbar = DescricaoDoSelecionado.GetComponentInChildren <Scrollbar>(); if (scrollbar) { scrollbar.value = 1; } //Atualizar descrição expandida para o nível de ensino selecionado descricaoExpandida.text = botaoSelecionado.Valor.Expansao; var spritePequeno = botaoSelecionado.ImageComponent.sprite; iconePequenoGuia.sprite = spritePequeno; paginaAreaDeConhecimento.DesfazerEscolha(); }; }
void Update() { Debug.Log("Delta Time: " + timedElapsed); //Fade In/Out between texts. if (GameObject.Find("Credits") is null) { timedElapsed += Time.deltaTime; scrollRect.velocity += new Vector2(0f, yAxisVelocityModifier); scrollRect.content.Translate(Vector3.up * scrollRect.velocity.y, Space.Self); scrollRect.GetComponentInChildren <Text>().color = new Color(scrollRect.GetComponentInChildren <Text>().color.r, scrollRect.GetComponentInChildren <Text>().color.g, scrollRect.GetComponentInChildren <Text>().color.b, Mathf.Lerp(scrollRect.GetComponentInChildren <Text>().color.a, 1.0f, transitionTime)); transitionTime += transitionTimeStep; } else { scrollRect.GetComponentInChildren <Text>().color = new Color(scrollRect.GetComponentInChildren <Text>().color.r, scrollRect.GetComponentInChildren <Text>().color.g, scrollRect.GetComponentInChildren <Text>().color.b, Mathf.Lerp(scrollRect.GetComponentInChildren <Text>().color.a, 0.0f, transitionTime)); transitionTime += transitionTimeStep; } //Reset Text Position. if (timedElapsed > (resetTimeInSeconds / (yAxisVelocityModifier + 0.01f))) { scrollRect.GetComponentInChildren <Text>().gameObject.GetComponent <RectTransform>().anchoredPosition3D = new Vector3(initialTextPos.x, initialTextPos.y, initialTextPos.z); timedElapsed = 0.0f; } transitionTime = transitionTimeStep; }
//Predicate<string> OnClickAction; public UIList() { dialogCanvas = GameObject.Find("UI_List"); button = dialogCanvas.GetComponentInChildren <Button>(); scrollRect = dialogCanvas.GetComponentInChildren <ScrollRect>(); contentText = scrollRect.GetComponentInChildren <Text>(); HideDialog(); }
private void Start() { Overlay = GetComponentInChildren <Canvas>(); Overlay.gameObject.SetActive(false); TextPrefab = GetComponentInChildren <Text>(); ScrollRect = Overlay.GetComponentInChildren <ScrollRect>(true); Content = ScrollRect.GetComponentInChildren <Image>(true).GetComponentInChildren <VerticalLayoutGroup>(true).gameObject; InputField = Overlay.GetComponentInChildren <InputField>(true); }
void Start() { Time.timeScale = 1.0f; //resets timescale to normal after returning from pause menu. transitionTime = transitionTimeStep; timedElapsed = 0.0f; scrollRectGO = GameObject.FindGameObjectWithTag("AutoScroll"); scrollRect = scrollRectGO.GetComponent <ScrollRect>(); initialTextPos = scrollRect.GetComponentInChildren <Text>().gameObject.GetComponent <RectTransform>().anchoredPosition3D; }
void Start() { if (equipmentDisplayPrefab.GetComponent <ItemInventoryDisplay>() == null) { Debug.LogError("Error! The Inventory Display Prefab must have an ItemInventoryDisplay!"); Application.Quit(); } scrollTitle = scrollRect.GetComponentInChildren <TextMeshProUGUI>(); //UnlockItems(); }
// Start is called before the first frame update void Start() { if (equipmentDisplayPrefab.GetComponent <EquipmentStockDisplay>() == null) { Debug.LogError("Error! Equipment Display Prefab does not have an EquipmentStockDisplay!"); Application.Quit(); } title = stockRect.GetComponentInChildren <TextMeshProUGUI>(); purchaseButtonTitle = purchaseButton.GetComponentInChildren <TextMeshProUGUI>(); }
private void Start() { spriteOriginalDoIconePequenoGuia = iconePequenoGuia.sprite; //Setar a descrição expandida inicial var descricaoExpandidaInicial = TextoExpandido; descricaoExpandidaInicial.text = "Agora você deve escolher a ÁREA DO CONHECIMENTO (ou CAMPOS DE APRENDIZAGEM) de acordo com o Nível de Ensino.\n\n" + "Todo o resto do seu planejamento será definido por essa escolha. Se você selecionou anteriormente algum nível da Educação Básica, procure ler " + "atentamente cada uma delas para aprender mais sobre o assunto de acordo com a nova divisão da Base Nacional Comum Curricular(BNCC).Se selecionou o " + "Ensino Superior, é importante aprender sobre como estão definidas de acordo com o Conselho Nacional de Desenvolvimento Cientítico e Tecnoloógico(CNPq)."; // Toda vez que o grupo de botões disser que um novo botão foi // selecionado, a página irá atualizar o ícone grande em destaque, // o nome do botão selecionado e o ícone pequeno na lateral esquerda foreach (var grupoDeIcones in IconesPorNivelDeEnsino.Values) { grupoDeIcones.QuandoUmElementoForSelecionadoEvent += (iconeSelecionado) => { iconeGrandeEmDestaque.sprite = iconeSelecionado.SpriteGrande; iconeGrandeEmDestaque.enabled = true; NomeDoSelecionado.text = iconeSelecionado.Valor.nome; // Atualizar descrição para a área de conhecimento selecionada var textoDaDescricaoDoSelecionado = DescricaoDoSelecionado.GetComponentInChildren <TextMeshProUGUI>(); textoDaDescricaoDoSelecionado.text = iconeSelecionado.Valor.Descricao; // Retornar/resetar scrollbar para o topo var scrollbar = DescricaoDoSelecionado.GetComponentInChildren <Scrollbar>(); if (scrollbar) { scrollbar.value = 1; } //Atualizar descrição no popup expandido para a area de conhecimento selecionada var descricaoExpandida = TextoExpandido; descricaoExpandida.text = iconeSelecionado.Valor.Expansao; var spritePequeno = iconeSelecionado.ImageComponent.sprite; iconePequenoGuia.sprite = spritePequeno; }; } }
private void Start() { // Limpar nome do selecionado, descrição do selecionado e esconder // icone em destaque pois não há seleção ainda NomeDoSelecionado.text = string.Empty; //Esconde descrição e ícone grande no início //DescricaoDoSelecionado.GetComponentInChildren<TextMeshProUGUI>().text = string.Empty; //iconeGrandeEmDestaque.enabled = false; //Setar a descrição expandida inicial var descricaoExpandida = TextoExpandido; descricaoExpandida.text = ""; // Toda vez que o grupo de botões disser que um novo botão foi // selecionado, a página irá atualizar o ícone grande em destaque, // o nome do botão selecionado e o ícone pequeno na lateral esquerda grupoDeBotoes.QuandoUmNovoBotaoForSelecionadoEvent += (botaoSelecionado) => { iconeGrandeEmDestaque.sprite = botaoSelecionado.SpriteGrande; iconeGrandeEmDestaque.enabled = true; NomeDoSelecionado.text = botaoSelecionado.Valor.nome; // Atualizar descrição para o nível de ensino selecionado var textoDaDescricaoDoSelecionado = DescricaoDoSelecionado.GetComponentInChildren <TextMeshProUGUI>(); textoDaDescricaoDoSelecionado.text = botaoSelecionado.Valor.descricao; // Retornar/resetar scrollbar para o topo var scrollbar = DescricaoDoSelecionado.GetComponentInChildren <Scrollbar>(); if (scrollbar) { scrollbar.value = 1; } //Atualizar descrição expandida para o nível de ensino selecionado descricaoExpandida.text = botaoSelecionado.Valor.expansao; }; }
protected virtual void Update() { var saveManager = FungusManager.Instance.SaveManager; // Hide the Save and Load buttons if autosave is on bool showSaveAndLoad = !autoSave; if (saveButton.IsActive() != showSaveAndLoad) { saveButton.gameObject.SetActive(showSaveAndLoad); loadButton.gameObject.SetActive(showSaveAndLoad); } if (showSaveAndLoad) { if (saveButton != null) { // Don't allow saving unless there's at least one save point in the history, // This avoids the case where you could try to load a save data with 0 save points. saveButton.interactable = saveManager.NumSavePoints > 0 && saveMenuActive; } if (loadButton != null) { loadButton.interactable = saveManager.SaveDataExists(saveDataKey) && saveMenuActive; } } if (restartButton != null) { restartButton.interactable = saveMenuActive; } if (rewindButton != null) { rewindButton.interactable = saveManager.NumSavePoints > 0 && saveMenuActive; } if (forwardButton != null) { forwardButton.interactable = saveManager.NumRewoundSavePoints > 0 && saveMenuActive; } if (debugView.enabled) { var debugText = debugView.GetComponentInChildren <Text>(); if (debugText != null) { debugText.text = saveManager.GetDebugInfo(); } } }
void Start() { _eventText = _textAreaScrollView.GetComponentInChildren <Text>(); if (_eventDatabase == null) { Debug.Log("GameEventDatabase not set, looking for one in resources."); _eventDatabase = Resources.FindObjectsOfTypeAll <GameEventDatabase>().First(); } if (_eventDatabase == null) { Debug.LogError("Unable to find a GameEventDatabase."); } GoToEvent("Start"); }
protected void UpdateNarrativeLogText() { if (narrativeLogView.enabled) { var historyText = narrativeLogView.GetComponentInChildren <Text>(); if (historyText != null) { historyText.text = FungusManager.Instance.NarrativeLog.GetPrettyHistory(); } Canvas.ForceUpdateCanvases(); narrativeLogView.verticalNormalizedPosition = 0f; Canvas.ForceUpdateCanvases(); } }
private void Awake() { stageParentTransform = stageScrollView.GetComponentInChildren <ContentSizeFitter>().transform; stageSlotList = new List <Transform>(); for (int i = 0; i < 100; i++) { GameObject slot = Instantiate(slotStagePrefab, stageParentTransform); slot.GetComponentInChildren <Text>().text = (i + 1).ToString(); int slotStageNumber = i + 1; slot.GetComponent <Button>().onClick.RemoveAllListeners(); slot.GetComponent <Button>().onClick.AddListener(delegate { OnSelectStage(slotStageNumber); }); slot.SetActive(true); stageSlotList.Add(slot.transform); } }
public static void SetHorizontalLayoutView(this RectTransform parent, int visibleColumns, RectTransform slotRect, bool middle) { ScrollRect scrollRect = parent.GetComponent <ScrollRect>() ?? parent.GetComponentInChildren <ScrollRect>(); HorizontalLayoutGroup grid = scrollRect.GetComponentInChildren <HorizontalLayoutGroup>(); RectTransform viewport = scrollRect.viewport; RectTransform content = scrollRect.content; int childCount = grid.transform.childCount; float slotRatio = slotRect.rect.width / slotRect.rect.height; float screenRatio = (float)Screen.width / (float)Screen.height; if (middle) { content.anchorMin = new Vector2(0.5f, 1); content.anchorMax = new Vector2(0.5f, 1); content.pivot = new Vector2(0.5f, 1); } else { content.anchorMin = new Vector2(0, 1); content.anchorMax = new Vector2(0, 1); content.pivot = new Vector2(0, 1); } float slotWidth = (viewport.rect.width - (grid.padding.left + grid.padding.right + (visibleColumns - 1) * grid.spacing)) / visibleColumns; float slotHeight = slotWidth / slotRatio; Vector2 slotSize = new Vector2(slotWidth, slotHeight); slotRect.sizeDelta = slotSize; float gridHeight = grid.padding.top + grid.padding.bottom + slotSize.y; parent.sizeDelta = new Vector2(parent.sizeDelta.x, gridHeight); foreach (Transform child in content) { child.GetComponent <RectTransform>().sizeDelta = slotSize; } }
// Use this for initialization private void Start() { Instance = this; _scrollview = GetComponentInChildren <ScrollRect>(); _textContent = _scrollview.GetComponentInChildren <Text>(); _scrollbar = _scrollview.verticalScrollbar; _style = new GUIStyle(); _style.font = _textContent.font; _style.fontStyle = _textContent.fontStyle; _style.fontSize = _textContent.fontSize; _needUpdate = 1; foreach (RectTransform t in GetComponentsInChildren <RectTransform>()) { if (t.name == "Title") { _yDelta = t.rect.height - t.offsetMax.y * 2; break; } } ToogleReduce(); }
// Start is called before the first frame update void Start() { ScrollRect scrollRect = puzzleSelectionToggleGroup.GetComponentInParent <ScrollRect>(); Scrollbar scrollbar = scrollRect.GetComponentInChildren <Scrollbar>(); for (int i = 0; i < puzzleDefinitions.Length; i++) { RectTransform toggleGroupRectTransform = puzzleSelectionToggleGroup.GetComponent <RectTransform>(); GameObject toggleGameObject = Instantiate <GameObject>(puzzleSelectionTogglePrefab, toggleGroupRectTransform); RectTransform toggleRectTransform = toggleGameObject.GetComponent <RectTransform>(); RectTransform scrollRectRectTransform = scrollRect.GetComponent <RectTransform>(); RectTransform scrollbarRectTransform = scrollbar.GetComponent <RectTransform>(); float toggleGroupWidth = scrollRectRectTransform.rect.width - scrollbarRectTransform.rect.width; toggleRectTransform.anchorMin = new Vector2(0, 1); toggleRectTransform.anchorMax = new Vector2(0, 1); toggleRectTransform.anchoredPosition = new Vector2(toggleGroupWidth / 2, -toggleGroupWidth * i); toggleRectTransform.sizeDelta = new Vector2(toggleGroupWidth, toggleGroupWidth); PuzzleDefinitionContainer container = toggleGameObject.GetComponent <PuzzleDefinitionContainer>(); container.puzzle.image = puzzleDefinitions[i].image; container.puzzle.revealText = puzzleDefinitions[i].revealText; Image toggleImage = toggleGameObject.GetComponentInChildren <Image>(); Vector2 imageSize = new Vector2(container.puzzle.image.width, container.puzzle.image.height); toggleImage.sprite = Sprite.Create(container.puzzle.image, new Rect(new Vector2(0, 0), imageSize), new Vector2(0.5f, 0.5f)); Toggle toggle = toggleGameObject.GetComponent <Toggle>(); toggle.group = puzzleSelectionToggleGroup; } puzzleSelectionToggleGroup.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 0); currentPuzzleDefinition = puzzleDefinitions[0]; StartNewGamePuzzle(); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); RectTransform rectTransform = target as RectTransform; ScrollRect scrollRect = rectTransform.GetComponent <ScrollRect>(); if (scrollRect != null) { Mask mask = scrollRect.GetComponentInChildren <Mask>(); Transform content = mask.transform.Find("Content"); HorizontalLayoutGroup horizontalLayoutGroup = content.GetComponent <HorizontalLayoutGroup>(); VerticalLayoutGroup verticalLayoutGroup = content.GetComponent <VerticalLayoutGroup>(); if (scrollRect.horizontal && !scrollRect.vertical) { if (verticalLayoutGroup != null) { Object.DestroyImmediate(verticalLayoutGroup); } if (horizontalLayoutGroup == null) { HorizontalLayoutGroup horizontalLayoutGroup_new = content.gameObject.AddComponent <HorizontalLayoutGroup>(); horizontalLayoutGroup_new.spacing = 10; } } else if (scrollRect.vertical && !scrollRect.horizontal) { if (horizontalLayoutGroup != null) { Object.DestroyImmediate(horizontalLayoutGroup); } if (verticalLayoutGroup == null) { VerticalLayoutGroup verticalLayoutGroup_new = content.gameObject.AddComponent <VerticalLayoutGroup>(); verticalLayoutGroup_new.spacing = 10; } } } }
public void Genearte() { for (int i = 0; i < 2; i++) { Data.Add(i); } v_layout = scrollRect.GetComponentInChildren <VerticalLayoutGroup>(); layout = v_layout.GetComponent <RectTransform>(); rt = scrollRect.GetComponent <RectTransform>(); rt.GetWorldCorners(scroll_rect_corner);//左下左上右上右下 scrollRectHight = rt.sizeDelta.y; scrollRect.onValueChanged.AddListener(OnValueChange); v_layout = layout.GetComponent <VerticalLayoutGroup>(); if (recycle) { for (int i = 0; i < 1; i++) { AddLast(i); } } MoveToBottom(); }
// Use this for initialization void Start() { chattingFlag = false; channelFlag = false; chatBar = GameObject.Find("Chatting_Bar").GetComponent <ScrollRect>(); chatText = chatBar.GetComponentInChildren <TextMeshProUGUI>(); chatContent = chatBar.content.gameObject; renderCanvas = GameObject.Find("renderCanvas").GetComponent <Canvas>(); chatQueue = new Queue <TextMeshProUGUI>(); otherPlayer = new Dictionary <ulong, Player>(); chDropdown = GameObject.Find("Channel").GetComponent <Dropdown>(); chDropdown.onValueChanged.AddListener(delegate { dropDownFunction(chDropdown); }); cineCamera = GameObject.Find("cineCamera").GetComponent <Cinemachine.CinemachineVirtualCamera>(); defaultPosition = new Vector2(-164.0f, 1110.0f); otherPlayerColor = new Color(183, 165, 119, 255); Scene = sceneManager.Instance; Network = NetworkManager.Instance; Network.setChatMng(this); request_playerData(); }
public void OnEnable() { #region Text 自动添加ContentSizeFitter组件 //这里的target 是在Editor中的变量 也就是当前对象 要里式转换一下 RectTransform rectTransform = target as RectTransform; Text text = rectTransform.GetComponent <Text>(); ContentSizeFitter contentSizeFitter = rectTransform.GetComponent <ContentSizeFitter>(); if (text != null) { if (text.raycastTarget) { text.raycastTarget = false; } if (contentSizeFitter == null) { ContentSizeFitter contentSizeFitter_new = rectTransform.gameObject.AddComponent <ContentSizeFitter>(); contentSizeFitter_new.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; contentSizeFitter_new.verticalFit = ContentSizeFitter.FitMode.PreferredSize; } } //else if (text == null && contentSizeFitter != null) //{ // Object.DestroyImmediate(contentSizeFitter); //} #endregion #region Raycast 自动关闭不需要的raycast RawImage rawImage = rectTransform.GetComponent <RawImage>(); Image image = rectTransform.GetComponent <Image>(); Button btn = rectTransform.GetComponent <Button>(); HorizontalOrVerticalLayoutGroup horizontalOrVerticalLayoutGroup = rectTransform.GetComponentInParent <HorizontalOrVerticalLayoutGroup>(); if (btn == null && horizontalOrVerticalLayoutGroup == null) { if (rawImage != null && rawImage.raycastTarget) { rawImage.raycastTarget = false; } if (image != null && image.raycastTarget) { image.raycastTarget = false; } } else { if (rawImage != null && !rawImage.raycastTarget) { rawImage.raycastTarget = true; } if (image != null && !image.raycastTarget) { image.raycastTarget = true; } } #endregion #region Scroll View 自动关闭scrollbar,设置mask锚点,添加content组件 ScrollRect scrollRect = rectTransform.GetComponent <ScrollRect>(); if (scrollRect != null) { scrollRect.horizontalScrollbar = null; scrollRect.verticalScrollbar = null; Scrollbar[] scrollBars = scrollRect.GetComponentsInChildren <Scrollbar>(); for (int i = 0; i < scrollBars.Length; i++) { scrollBars[i].gameObject.SetActive(false); } Mask mask = scrollRect.GetComponentInChildren <Mask>(); mask.rectTransform.anchorMin = Vector2.one / 2; mask.rectTransform.anchorMax = Vector2.one / 2; mask.rectTransform.pivot = Vector2.one / 2; if (scrollRect.horizontalScrollbar == null) { mask.rectTransform.SetSizeDelta(scrollRect.GetComponent <RectTransform>().sizeDelta); } Transform content = mask.transform.Find("Content"); ContentSizeFitter contentSizeFitter_new = content.GetComponent <ContentSizeFitter>(); if (contentSizeFitter_new == null) { ContentSizeFitter contentSizeFitter_new_add = content.gameObject.AddComponent <ContentSizeFitter>(); contentSizeFitter_new_add.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; contentSizeFitter_new_add.verticalFit = ContentSizeFitter.FitMode.PreferredSize; } } #endregion }
private void Awake() { shopItemParentTransform = ShopItemScrollView.GetComponentInChildren <ContentSizeFitter>().transform; }