public void loadCardProgress()
    {
        cardProgListItemMap = new Dictionary <string, GameObject>();
        foreach (Transform child in cardProgressListTransform)
        {
            GameObject.Destroy(child.gameObject);
        }

        currentPreviewedCard = PlayerCardProgress.Instance().cards.Values.First().card;
        previewCard(currentPreviewedCard);

        foreach (CardProgress cardProg in PlayerCardProgress.Instance().cards.Values)
        {
            addCardProg(cardProg, false);
        }

        LayoutRebuilder.ForceRebuildLayoutImmediate(cardProgressListTransform as RectTransform);
    }
Ejemplo n.º 2
0
 private void Btn_OpenSize()  // 打开大小设置
 {
     if (!go_ModeSize.activeSelf)
     {
         anim_SizeIcon.DOPlayForward();
         LayoutRebuilder.ForceRebuildLayoutImmediate(rt_Right);
         go_ModeSize.SetActive(true);
         if (go_ModeFilter.activeSelf && go_ModeSorting.activeSelf)
         {
             Btn_CloseFilter();
             Btn_CloseSorting();
         }
     }
     else
     {
         Btn_CloseSize();
     }
 }
Ejemplo n.º 3
0
    private RectTransform AddLast(int i)
    {
        bool valid = Data.Contains(i);

        if (!valid)
        {
            return(null);
        }
        RectTransform r = CreateNew();

        AssignValue(r, i);
        r.SetAsLastSibling();
        list.AddLast(r);
        end.SetAsLastSibling();
        LayoutRebuilder.ForceRebuildLayoutImmediate(layout);
        ResizeLayout();
        return(r);
    }
    ChatInfo AddData(string msg)
    {
        prefab_txt.text = msg;
        prefab_txt.ForceMeshUpdate();

        LayoutRebuilder.ForceRebuildLayoutImmediate(rt_prefab);
        ChatInfo info = GetDataFromPool();

        info.msg    = msg;
        info.y      = data.Count > 0 ? data[data.Count - 1].y - data[data.Count - 1].height : 0;
        info.height = rt_prefab.sizeDelta.y;
        data.Add(info);

        contentHeight += info.height;
        content.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, contentHeight);

        return(info);
    }
Ejemplo n.º 5
0
 public void OnPointerEnter(PointerEventData eventData)
 {
     if (eventData.dragging)
     {
         ghost = Instantiate(eventData.pointerDrag, content);
         RectTransform r = ghost.transform as RectTransform;
         r.sizeDelta = new Vector2(r.sizeDelta.x, InstructionList.height);
         index       = this.GetIndex(eventData);
         if (index == list.GetLength())
         {
             index--;
         }
         list.ghostIndex = index;
         ghost.transform.SetSiblingIndex(index);
         LayoutRebuilder.ForceRebuildLayoutImmediate(content);
         isDragging = true;
     }
 }
    public void LoadResult(GameObject[] cardObjects, List <GameObject> playerObjects)
    {
        GameObject panelResult = gameCanvas.transform.Find("GameResult/PlayerPoints/Viewport/Content").gameObject;

        // # LOAD RESULTS DATA
        // Load player headers
        GameObject playerHeaders = LoadPlayerHeaders(panelResult);
        // Load card player points
        Dictionary <string, GameObject> cardPlayerPoints = LoadCardPlayerPoints(panelResult, cardObjects);
        // Load gold results
        GameObject goldResults = LoadGoldResults(panelResult);

        // # CALC RESULTS DATA
        playerWinner = CalcResult(playerHeaders, cardPlayerPoints, goldResults, playerObjects);

        // Refresh panel result layout
        LayoutRebuilder.ForceRebuildLayoutImmediate(panelResult.GetComponent <RectTransform>());
    }
Ejemplo n.º 7
0
        public void DisplayInfo(HotbarItem infoItem)
        {
            //Create a string builder instance.
            StringBuilder builder = new StringBuilder();

            //Get the item's custom display text.
            builder.Append("<size=35>").Append(infoItem.ColouredName).Append("</size>\n");
            builder.Append(infoItem.GetInfoDisplayText());

            //Set info text to be displayed.
            infoText.text = builder.ToString();

            //Activate UI canvas object.
            popupCanvasObject.SetActive(true);

            //Fixes resize problem.
            LayoutRebuilder.ForceRebuildLayoutImmediate(popupObject);
        }
Ejemplo n.º 8
0
 private void FocusGroup(string groupName)
 {
     if (string.IsNullOrEmpty(groupName))
     {
         return;
     }
     for (int i = 0; i < groupArr.Length; i++)
     {
         var group = groupArr[i];
         if (group != null && group.groupName == groupName)
         {
             LayoutRebuilder.ForceRebuildLayoutImmediate(Content.rectTransform);
             Content.rectTransform.localPosition = new Vector3(Content.rectTransform.localPosition.x, -group.Pos - Viewport.rectTransform.rect.height / 2, Content.rectTransform.localPosition.z);
             group.PlayShowAnim();
             break;
         }
     }
 }
Ejemplo n.º 9
0
        private void OnExpandedChanged(bool isExpanded)
        {
            if (isExpanded)
            {
                contentHolder.gameObject.SetActive(true);

                GenerateFields();
            }
            else
            {
                PoolFields();
                contentHolder.gameObject.SetActive(false);
                rect.sizeDelta = new Vector2(rect.sizeDelta.x, originalHeight);
            }

            //LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)rect.parent);
            LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)rect.parent.parent.parent);
        }
Ejemplo n.º 10
0
    private void showToast(string message, float second)
    {
        toastPanel.GetComponent <Image>().color   = new Color(toastPanel.GetComponent <Image>().color.r, toastPanel.GetComponent <Image>().color.g, toastPanel.GetComponent <Image>().color.b, 1);
        toastText.GetComponent <TMP_Text>().color = new Color(toastText.GetComponent <TMP_Text>().color.r, toastText.GetComponent <TMP_Text>().color.g, toastText.GetComponent <TMP_Text>().color.b, 1);

        toastText.SetActive(true);
        toastText.GetComponent <TMP_Text>().text = message;

        LayoutRebuilder.ForceRebuildLayoutImmediate(toastText.GetComponent <RectTransform>());

        toastPanel.SetActive(true);
        toastPanel.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, toastText.GetComponent <RectTransform>().rect.width + 25f);

        leftTime  = second;
        totalTime = second;

        fading = true;
    }
Ejemplo n.º 11
0
    public void Init(PlayerProfile playerProfile, string voiceName, MicProfile micProfile)
    {
        this.PlayerProfile      = playerProfile;
        this.MicProfile         = micProfile;
        this.Voice              = GetVoice(songMeta, voiceName);
        this.playerUiController = Instantiate(playerUiControllerPrefab, playerUiArea.transform);

        // Recalculate layout
        LayoutRebuilder.ForceRebuildLayoutImmediate(playerUiArea.GetComponent <RectTransform>());

        this.childrenInjector = CreateChildrenInjectorWithAdditionalBindings();

        // Inject all
        childrenInjector.InjectAllComponentsInChildren(this);
        childrenInjector.InjectAllComponentsInChildren(playerUiController);

        SetDisplaySentenceIndex(0);
    }
Ejemplo n.º 12
0
 private void InitTooltip(string content)
 {
     tooltipTrans.sizeDelta = new Vector2(0.25f, 0.25f);
     tooltipImg.gameObject.SetActive(true);
     isTrigger       = true;
     lifeTimeCounter = LifeTime;
     //-----------------------------------------------//
     /// SET TEXT AND RE-CALCULATE SIZE BOUNDING BOX ///
     //-----------------------------------------------//
     contentTxt.gameObject.SetActive(true);
     //Canvas.ForceUpdateCanvases();
     contentTxt.text = content;
     LayoutRebuilder.ForceRebuildLayoutImmediate(txtRectTrans);
     dimention             = txtRectTrans.sizeDelta;
     dimention             = dimention + dimention * 0.5f;
     txtFadeColor.IsFadeIn = true;
     contentTxt.gameObject.SetActive(false);
 }
        public void DisplayInfo(HotBarItem infoItem)
        {
            //create stringbuilder instance
            StringBuilder builder = new StringBuilder();

            //get item's custom display txt
            builder.Append("<size=35>").Append(infoItem.ColoredName).Append("</size>\n");
            builder.Append(infoItem.GetInfoDisplayText());

            //sets info text for display
            infoText.text = builder.ToString();

            //activates UI canvas
            popupCanvasObject.SetActive(true);

            //fix resize
            LayoutRebuilder.ForceRebuildLayoutImmediate(popupObject);
        }
Ejemplo n.º 14
0
        public void FixPos()
        {
            if (forceRect == true)
            {
                try
                {
                    LayoutRebuilder.ForceRebuildLayoutImmediate(GetComponent <RectTransform>());
                }

                catch { }
            }

            else
            {
                gameObject.SetActive(false);
                gameObject.SetActive(true);
            }
        }
Ejemplo n.º 15
0
        private void OnEmissionReactValueChanged(bool enabled)
        {
            LineModel newLineModel = _lineModel.DeepCopy();

            if (enabled)
            {
                newLineModel.IsEmissionEnabled = true;
                _emissionSwitch.toggle.isOn    = true;
            }

            newLineModel.EmissionProperty.IsEmissionReactOnAudio = enabled;
            UpdateLineModel(newLineModel);
            _emissionThresholdSlider.gameObject.SetActive(enabled);
            _emissionBandBufferSlider.gameObject.SetActive(enabled);
            _emissionFrequencyDropdown.gameObject.SetActive(enabled);
            LayoutRebuilder.ForceRebuildLayoutImmediate(_verticalLayoutGroup.GetComponent <RectTransform>());
            UpdateLineSignal.Dispatch(newLineModel);
        }
    public static int ForceRebuildLayoutImmediate_s(IntPtr l)
    {
        int result;

        try
        {
            RectTransform layoutRoot;
            LuaObject.checkType <RectTransform>(l, 1, out layoutRoot);
            LayoutRebuilder.ForceRebuildLayoutImmediate(layoutRoot);
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Ejemplo n.º 17
0
 /// <summary>
 /// Method that rebuilds the UI layout after two frame updates
 /// </summary>
 /// <param name="transformToRebuild">Transform that will be rebuilt</param>
 public static void LayoutRebuild(RectTransform transformToRebuild)
 {
     if (transformToRebuild == null)
     {
         return;
     }
     //Layout rebuild is required after one frame when content changes size
     LayoutRebuilder.ForceRebuildLayoutImmediate(transformToRebuild);
     do
     {
         transformToRebuild = transformToRebuild.parent as RectTransform;
         if (transformToRebuild != null && (transformToRebuild.GetComponent <ContentSizeFitter>() != null ||
                                            transformToRebuild.GetComponent <LayoutGroup>() != null))
         {
             LayoutRebuilder.ForceRebuildLayoutImmediate(transformToRebuild);
         }
     } while (transformToRebuild != null);
 }
Ejemplo n.º 18
0
    private void Update()
    {
        if (tooltip.activeSelf)
        {
            LayoutRebuilder.ForceRebuildLayoutImmediate(tooltip.GetComponent <RectTransform>());
        }

        if (quantityInStock <= 0 && !unlimitedQuantity)
        {
            outOfStock.enabled  = true;
            button.interactable = false;

            //ClearSlot();
            Debug.Log("Clear");
        }
        else if (item != null)
        {
            outOfStock.enabled  = false;
            icon.sprite         = item.sprite;
            button.interactable = true;
        }

        if (!unlimitedQuantity)
        {
            quantity.text = quantityInStock.ToString();
        }
        else
        {
            quantity.text = string.Empty;
        }

        if (item == null)
        {
            //ShopUI.instance.shopSlots.Remove(this);
            //Destroy(gameObject);

            ClearSlot();
            gameObject.SetActive(false);
        }
        else
        {
            gameObject.SetActive(true);
        }
    }
Ejemplo n.º 19
0
    public void UpdateOrderList()
    {
        for (int i = 0; i < orderListRect.transform.childCount; i++)
        {
            print("delete" + (orderListRect.transform.GetChild(i).name));
            GameObject.Destroy(orderListRect.transform.GetChild(i).gameObject);
        }
        DeliveryBehavior delivery = FindObjectOfType <DeliveryBehavior>();

        foreach (Order order in delivery.activeOrderList)
        {
            GameObject go = GameObject.Instantiate(orderPrefab, orderListRect);
            //go.transform.SetParent(orderListRect);
            OrderGUI goGui = go.GetComponent <OrderGUI>();

            Recipe recipe = order.FoodItems[0]; //TODO make recusive

            List <Image> goGuiImages = new List <Image>();
            goGuiImages.Add(goGui.BreadingIcon1);
            goGuiImages.Add(goGui.BreadingIcon2);

            goGui.RecipeIcon.sprite = order.icon;
            if (recipe.BreadingLayers.Count > 1)
            {
                for (int i = 1; i < recipe.BreadingLayers.Count; i++)
                {
                    if (recipe.BreadingLayers[i] == FoodBehavior.BreadingType.Breading)
                    {
                        goGuiImages[i - 1].sprite = breading1;
                        goGuiImages[i - 1].color  = Color.white;
                    }

                    if (recipe.BreadingLayers[i] == FoodBehavior.BreadingType.Spicy)
                    {
                        goGuiImages[i - 1].sprite = breading2;
                        goGuiImages[i - 1].color  = Color.white;
                    }
                }
            }
            orderListRect.ForceUpdateRectTransforms();
            LayoutRebuilder.ForceRebuildLayoutImmediate(orderListRect);
            LayoutRebuilder.MarkLayoutForRebuild(orderListRect);
        }
    }
Ejemplo n.º 20
0
    IEnumerator Judge()
    {
        yield return(new WaitForEndOfFrame());

        yield return(null);

        //单行 默认是多行
        if (textRectTransform.sizeDelta.x > MAX_WIDTH)//超宽文本限制宽度【宽度超出】
        {
            //文本大小扩展
            TextSizeFitter.horizontalFit = ContentSizeFitter.FitMode.Unconstrained;
            TextSizeFitter.verticalFit   = ContentSizeFitter.FitMode.PreferredSize;
            textRectTransform.sizeDelta  = new Vector2(MAX_WIDTH, textRectTransform.sizeDelta.y);
            //文本气泡大小扩展
            yield return(null);

            bubbleSizeFitter.horizontalFit = ContentSizeFitter.FitMode.Unconstrained;
            bubbleSizeFitter.verticalFit   = ContentSizeFitter.FitMode.PreferredSize;
            //消息项所占长度扩展
            yield return(null);

            LayoutRebuilder.ForceRebuildLayoutImmediate(msgRectTransform);
        }
        else//根据当前的宽度适配长度【宽度没超出,长度超出一行】
        {
            TextSizeFitter.horizontalFit = ContentSizeFitter.FitMode.Unconstrained;
            TextSizeFitter.verticalFit   = ContentSizeFitter.FitMode.PreferredSize;

            yield return(null);

            bubbleSizeFitter.horizontalFit = ContentSizeFitter.FitMode.Unconstrained;
            bubbleSizeFitter.verticalFit   = ContentSizeFitter.FitMode.PreferredSize;


            yield return(null);

            LayoutRebuilder.ForceRebuildLayoutImmediate(msgRectTransform);
        }
        //消息滚动窗内容大小及位置刷新
        yield return(null);//等一帧

        LayoutRebuilder.ForceRebuildLayoutImmediate(transform.parent.GetComponent <RectTransform>());
        transform.parent.parent.parent.GetComponent <ScrollRect>().verticalNormalizedPosition = 0;//至于滚动视图底部
    }
    public LayoutDimensions PrecalculateCellLayoutData(CellData cellData, LayoutAxis axis)
    {
        // Set up the proxy cell to reflect the same layout and rect as our cell would be instantiated as
        var recyclerCell = CellPool.CellProxy.GetComponent <IRecyclableCell>();
        var proxyRtx     = (RectTransform)CellPool.CellProxy.transform;

        recyclerCell.OnCellInstantiate();
        recyclerCell.OnCellShow(cellData);
        LayoutRebuilder.ForceRebuildLayoutImmediate(proxyRtx);

        LayoutAxis initialAxis =
            (ICellLayout.LayoutGroup is VerticalCellLayout) ? LayoutAxis.Horizontal : LayoutAxis.Vertical;
        LayoutAxis secondaryAxis =
            (initialAxis == LayoutAxis.Horizontal) ? LayoutAxis.Vertical : LayoutAxis.Horizontal;

        var             iLayout  = CellPool.CellProxy.GetComponent <ILayoutElement>();
        Action <string> dbgPrint = (string msg) =>
        {
            //Debug.Log(string.Format("{0} proxyRtx.rect.size = {1} preferredSize = {2} minSize = {3} flexibleSize = {4}",
            //    msg,
            //    proxyRtx.rect.size,
            //    new Vector2(iLayout.preferredWidth, iLayout.preferredHeight),
            //    new Vector2(iLayout.minWidth, iLayout.minHeight),
            //    new Vector2(iLayout.flexibleWidth, iLayout.flexibleHeight)));
        };

        Action <string> placeCell = (string message) =>
        {
            PlaceCell(proxyRtx, initialAxis);
            dbgPrint(message + "Initial Axis: ");
            PlaceCell(proxyRtx, secondaryAxis);
            dbgPrint(message + "Secondary Axis: ");
        };

        placeCell("FIRST FRAME (1): ");

        LayoutRebuilder.ForceRebuildLayoutImmediate(proxyRtx);

        placeCell("FIRST FRAME (2): ");

        CoroutineRunner.WaitForEndOfFrame(() => placeCell("SECOND FRAME: "));

        return(GetProxyLayoutDimensions(axis));
    }
Ejemplo n.º 22
0
        public bool Select(Transform selection)
        {
            if (selection.IsNull())
            {
                Deselect();
                return(true);
            }
            else
            {
                if (selection == CurrentSelection)
                {
                    return(true);
                }

                Scene selectionScene = selection.gameObject.scene;
                for (int i = 0; i < sceneDrawers.Count; i++)
                {
                    IHierarchyRootContent content = sceneDrawers[i].Content;
                    if ((content is HierarchyRootPseudoScene) || ((HierarchyRootScene)content).Scene == selectionScene)
                    {
                        HierarchyItem selectionItem = sceneDrawers[i].SelectTransform(selection);
                        if (selectionItem != null)
                        {
                            if (drawArea.sizeDelta.y > 0f)
                            {
                                // Focus on selected HierarchyItem
                                LayoutRebuilder.ForceRebuildLayoutImmediate(drawArea);
                                //Vector3 localPos = drawArea.InverseTransformPoint(selectionItem.transform.position);
                                //scrollView.verticalNormalizedPosition = Mathf.Clamp01(1f + localPos.y / drawArea.sizeDelta.y);
                                Vector2 pos =
                                    (Vector2)scrollView.transform.InverseTransformPoint(drawArea.position)
                                    - (Vector2)scrollView.transform.InverseTransformPoint(selectionItem.transform.position);
                                pos.x = drawArea.anchoredPosition.x;
                                drawArea.anchoredPosition = pos;
                            }

                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 23
0
    private void BuildChatMessageUI(string messageWho, string messageMessage, GameObject messageTextObjectPrefab, RectTransform chatMessagesViewContent, List <GameObject> chatMessages)
    {
        //if (gameObject.activeSelf)
        //{
        GameObject messageTextObject             = Instantiate(messageTextObjectPrefab) as GameObject;
        var        messageTextObjectChildrenText = messageTextObject.GetComponentsInChildren <TMPro.TextMeshProUGUI>();

        TMPro.TextMeshProUGUI playerText  = messageTextObjectChildrenText[0];
        TMPro.TextMeshProUGUI messageText = messageTextObjectChildrenText[1];

        if (messageWho.Length >= 20)
        {
            playerText.text = ("<b>" + messageWho.Substring(0, 17) + "..." + ":</b>");
        }
        else
        {
            playerText.text = ("<b>" + messageWho + ":</b>");
        }
        messageText.text = messageMessage;

        if (SceneManager.GetActiveScene().name == "MainMenu")
        {
            if (messageWho != gameSparksUserIDScript.myDisplayName)
            {
                StartCoroutine(nameof(BuyTime));
            }
        }


        Debug.Log("Name Of ChatMessagesViewContent: " + chatMessagesViewContent.name);
        messageTextObject.transform.SetParent(chatMessagesViewContent);
        messageTextObject.transform.localScale = new Vector3(1, 1, 1);

        chatMessages.Add(messageTextObject);

        LayoutRebuilder.ForceRebuildLayoutImmediate(chatMessagesViewContent);

        //AddSpacingMessage(chatMessagesViewContent, chatMessages, messageTextObjectPrefab);
        //chatMessagesViewContent.parent.gameObject.GetComponentInChildren<Scrollbar>().value = 0;
        StartCoroutine(ScrollToBottom());

        LayoutRebuilder.ForceRebuildLayoutImmediate(chatMessagesViewContent);
        //}
    }
Ejemplo n.º 24
0
        /// <summary>
        /// Calculates if the ScrollRect should be scrollable based on the content height and sets the ScrollRect height.
        /// </summary>
        private void RefreshLayout()
        {
            if (!m_ScrollRect)
            {
                m_ScrollRect = GetComponent <ScrollRect>();
            }
            if (!m_ScrollRectTransform)
            {
                m_ScrollRectTransform = m_ScrollRect.GetComponent <RectTransform>();
            }

            LayoutRebuilder.ForceRebuildLayoutImmediate(contentRectTransform);

            float tempHeight = LayoutUtility.GetPreferredHeight(contentRectTransform);

            if (tempHeight > m_MaxHeight)
            {
                m_Height = maxHeight;
                m_ScrollRect.movementType   = movementTypeWhenScrollable;
                m_ScrollHandleImage.enabled = true;

                m_ScrollEnabled = true;

                for (int i = 0; i < m_ShowWhenScrollable.Length; i++)
                {
                    m_ShowWhenScrollable[i].enabled = true;
                }
            }
            else
            {
                m_Height = tempHeight;
                m_ScrollRect.movementType   = ScrollRect.MovementType.Clamped;
                m_ScrollHandleImage.enabled = false;

                m_ScrollEnabled = false;

                for (int i = 0; i < m_ShowWhenScrollable.Length; i++)
                {
                    m_ShowWhenScrollable[i].enabled = false;
                }
            }

            m_ScrollRectTransform.sizeDelta = new Vector2(m_ScrollRectTransform.sizeDelta.x, m_Height);
        }
Ejemplo n.º 25
0
    public void RefreshHeight()
    {
        if (LobbyScene.Get().GetBattleStage().IsLoaded())
        {
            return;
        }
        if (UIWindow.IsLoaded())
        {
            return;
        }

        LayoutRebuilder.ForceRebuildLayoutImmediate(gridParent.GetComponent <RectTransform>());

        float totalHeight = 55; //Rect Top + Bottom size

        QuestProgressText[] qpts = gridParent.GetComponentsInChildren <QuestProgressText>();
        foreach (QuestProgressText qpt in qpts)
        {
            MissionProgressText mpt = qpt.GetComponentInChildren <MissionProgressText>();

            if (mpt != null)
            {
                LayoutRebuilder.ForceRebuildLayoutImmediate(mpt.GetComponent <RectTransform>());
            }

            RectTransform rt = qpt.GetComponent <RectTransform>();
            LayoutRebuilder.ForceRebuildLayoutImmediate(rt);
            totalHeight += rt.rect.height + 2; // + cell spacing
        }

        const float originHeightSize = 400.0f;

        //최초 사이즈보다 크면 늘린다
        if (totalHeight > originHeightSize)
        {
            totalHeight = originHeightSize;
        }

        rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, totalHeight);

        uiArrowCollidie.localScale    = new Vector3(rectTransform.sizeDelta.x + 100f, rectTransform.sizeDelta.y, 1);
        uiArrowCollidie.localPosition = new Vector3(uiArrowCollidie.localScale.x / 2f, -(uiArrowCollidie.localScale.y / 2f), 0);
    }
Ejemplo n.º 26
0
    //Show the script in the container
    public static void ScriptToContainer(Script script, GameObject container, bool sensitive = false)
    {
        int i = 0;

        foreach (Action action in script.actions)
        {
            if (i == script.currentAction)
            {
                ActionToContainer(action, true).transform.SetParent(container.transform, sensitive);
            }
            else
            {
                ActionToContainer(action, false).transform.SetParent(container.transform, sensitive);
            }
            i++;
        }

        LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)container.transform);
    }
        //Private Methods:
        private void UpdateConsole()
        {
            string output = "";

            int length = _index + maxVisible;

            length = Mathf.Clamp(length, length, _conditions.Count);

            for (int i = _index; i < length; i++)
            {
                output += _conditions[i];

                if (showStackTrace)
                {
                    output += _stackTrace[i];
                }

                //trailing new line:
                if (i != _index + maxVisible)
                {
                    output += "\n";
                }
            }
            logText.text = output;

            //update rects:
            foreach (var item in GetComponentsInChildren <RectTransform>())
            {
                LayoutRebuilder.ForceRebuildLayoutImmediate(item);
            }

            //caculate scroller:
            Vector3 position = Vector3.Lerp(scrollMin.position, scrollMax.position, (float)_index / _bottomIndex);

            //nan protection:
            if (float.IsNaN(position.x) || float.IsNaN(position.y) || float.IsNaN(position.z))
            {
                position = scrollMin.position;
            }

            //update scroller:
            scrollHandle.position = Vector3.Lerp(scrollMin.position, scrollMax.position, (float)_index / _bottomIndex);
        }
Ejemplo n.º 28
0
    /// <summary>
    /// 创建item
    /// </summary>
    /// <param name="data"></param>
    async UniTask CreationShowItem(ChatInfo data)
    {
        RectTransform itemRect = GetItemRect();
        Text          showText = itemRect.GetComponent <Text>();
        string        prefix   = "";

        if (_allPrivateChats.Contains(data))
        {
            prefix = StaticData.GetMultilingual(120318);
        }
        else if (_allWorldDatas.Contains(data))
        {
            prefix = StaticData.GetMultilingual(120317);
        }
        showText.text = prefix + data._message;
        itemRect.gameObject.SetActive(true);
        LayoutRebuilder.ForceRebuildLayoutImmediate(itemRect);
        await SetItemPoint(itemRect);
    }
Ejemplo n.º 29
0
    public void Initialize(string titleText, string descText, string counterText, bool isOptionnal, float delay)
    {
        // set the description for the objective, and forces the content size fitter to be recalculated
        Canvas.ForceUpdateCanvases();

        titleTextContent.text       = titleText;
        descriptionTextContent.text = descText;
        counterTextContent.text     = counterText;

        if (GetComponent <RectTransform>())
        {
            LayoutRebuilder.ForceRebuildLayoutImmediate(GetComponent <RectTransform>());
        }

        m_StartFadeTime = Time.time + delay;
        // start the fade in
        m_IsFadingIn = true;
        m_IsMovingIn = true;
    }
Ejemplo n.º 30
0
        private void UpdateSelectedAutoComplete()
        {
            topMoreCommands.SetActive(verticalScrollIndex != 0);
            bottomMoreCommands.SetActive(matchingConObjectsCount > currentControllers.Count && verticalScrollIndex < matchingConObjectsCount - showMaxAutocompletes);

            for (int i = 0; i < currentControllers.Count; i++)
            {
                if (i == selectedAutoCompleteIndex)
                {
                    currentControllers[i].Select();
                }
                else
                {
                    currentControllers[i].Deselect();
                }
            }

            LayoutRebuilder.ForceRebuildLayoutImmediate(templateParentRect);
        }