Example #1
0
        public void TestCalculateLayoutInputHorizontal()
        {
            m_LayoutGroup.CalculateLayoutInputHorizontal();
            m_LayoutGroup.SetLayoutHorizontal();
            m_LayoutGroup.CalculateLayoutInputVertical();
            m_LayoutGroup.SetLayoutVertical();

            Assert.AreEqual(31, m_LayoutGroup.minWidth);
            Assert.AreEqual(206, m_LayoutGroup.preferredWidth);
            Assert.AreEqual(1, m_LayoutGroup.flexibleWidth);
        }
    private void Update()
    {
        /// Updates the chat UI on the next frame
        if (waitForUpdate)
        {
            verticalLayout.enabled = true;
            verticalLayout.CalculateLayoutInputVertical();
            verticalLayout.SetLayoutVertical();
            LayoutRebuilder.ForceRebuildLayoutImmediate(messagesParent as RectTransform);
            Canvas.ForceUpdateCanvases();

            waitForUpdate = false;
        }
    }
Example #3
0
    /// <summary>
    /// debugのテキストを受け取る
    /// </summary>
    private void OnReceive(string condition, string trace, LogType logType)
    {
        if (m_PrintText == null)
        {
            return;
        }

        var text = m_PrintText.text;

        switch (logType)
        {
        case LogType.Log:
            text += string.Format("{0}<color=#000000>{1}</color>{0}<color=#a0a0a0>{2}</color>{0}", System.Environment.NewLine, condition, trace);
            break;

        case LogType.Warning:
            text += string.Format("{0}<color=#adad00>{1}</color>{0}<color=#a0a000>{2}</color>{0}", System.Environment.NewLine, condition, trace);
            break;

        default:
            text += string.Format("{0}<color=#ad0000>{1}</color>{0}<color=#a00000>{2}</color>{0}", System.Environment.NewLine, condition, trace);
            break;
        }

        m_PrintText.text = text;
        m_VerticalLayoutGroup.CalculateLayoutInputVertical();
    }
Example #4
0
 void ForceUpdateLayout()
 {
     Canvas.ForceUpdateCanvases();
     topPanelLayout.CalculateLayoutInputVertical();
     topPanelLayout.SetLayoutVertical();
     topPanelFitter.SetLayoutVertical();
 }
Example #5
0
        public static void FixVerticalLayoutGroupFitting(UnityEngine.Object value)
        {
            VerticalLayoutGroup group = null;

            if (value is VerticalLayoutGroup)
            {
                group = value as VerticalLayoutGroup;
            }
            else if (value is GameObject)
            {
                group = (value as GameObject).GetComponent <VerticalLayoutGroup>();
            }
            else if (value is Transform)
            {
                group = (value as Transform).GetComponent <VerticalLayoutGroup>();
            }


            if (group == null)
            {
                return;
            }

            group.enabled = false;
            Canvas.ForceUpdateCanvases();
            group.SetLayoutVertical();
            group.CalculateLayoutInputVertical();
            group.enabled = true;
        }
Example #6
0
        public void CheckFinish()
        {
            if (!Cars.All(car => car.IsFinished()))
            {
                return;
            }

            IsFinished = true;
            winScreen.SetActive(true);

            // Create all leaderboard entries
            _leaderboard.GetEntries().ForEach(entry =>
            {
                var lead      = Instantiate(largeLeaderboardPlayerPrefab, largeLeaderboard, false);
                var component = lead.GetComponent <LargeLeaderboardPlayer>();

                var seconds = Mathf.FloorToInt(entry.NeededTime);
                var minutes = Mathf.FloorToInt(seconds / 60f);
                seconds    -= minutes * 60;

                component.positionLabel.text = entry.positionLabel.text;
                component.nameLabel.text     = $"Player {entry.PlayerId} ({minutes:00}:{seconds:00})";
            });

            verticalLayoutGroup.CalculateLayoutInputVertical();
        }
 // Update is called once per frame
 void Update()
 {
     Canvas.ForceUpdateCanvases();
     hlg.CalculateLayoutInputHorizontal();
     hlg.CalculateLayoutInputVertical();
     hlg.SetLayoutHorizontal();
     hlg.SetLayoutVertical();
 }
Example #8
0
 private void SetText(string text)
 {
     question.text = text.Replace("\\n", "\n"); // because [SerializeField] Unity is sucky
     Canvas.ForceUpdateCanvases();
     layout.CalculateLayoutInputVertical();
     layout.SetLayoutVertical();
     fitter.SetLayoutVertical();
 }
    // Update is called once per frame
    void Update()
    {
        VerticalLayoutGroup hlg = gameObject.GetComponent <VerticalLayoutGroup>();

        Canvas.ForceUpdateCanvases();
        hlg.CalculateLayoutInputHorizontal();
        hlg.CalculateLayoutInputVertical();
        hlg.SetLayoutHorizontal();
        hlg.SetLayoutVertical();
    }
Example #10
0
 void SetSize()
 {
     if (backgroundlayout == null)
     {
         Init();
     }
     Canvas.ForceUpdateCanvases();
     textSize.SetLayoutVertical();
     backgroundlayout.CalculateLayoutInputVertical();
     backgroundSize.SetLayoutVertical();
 }
    // HACK: Fix for an issue caused by the combined use of nested layout groups and content size fitter
    private IEnumerator ResetLayoutGroup()
    {
        yield return(new WaitForEndOfFrame());

        VerticalLayoutGroup verticalLayoutGroup = GetComponentInChildren <VerticalLayoutGroup>();

        verticalLayoutGroup.CalculateLayoutInputHorizontal();
        verticalLayoutGroup.CalculateLayoutInputVertical();
        verticalLayoutGroup.SetLayoutHorizontal();
        verticalLayoutGroup.SetLayoutVertical();
        yield break;
    }
    private IEnumerator RefreshLayoutCoroutine()
    {
        yield return(null); // skip a frame. Wait until canvases are done updating.

        vertLayoutGroup.CalculateLayoutInputVertical();
        vertLayoutGroup.SetLayoutVertical();
        //LayoutRebuilder.ForceRebuildLayoutImmediate(myRectTransform);
        float groupHeight = vertLayoutGroup.preferredHeight;

        // Apply the proper height.
        myRectTransform.sizeDelta = new Vector2(myRectTransform.sizeDelta.x, groupHeight + 20);// Mathf.Abs(rt_if_phonetic.anchoredPosition.y)+rt_if_phonetic.rect.size.y);
    }
 public void Init(EventChoice choice, DialogueManager parent)
 {
     if (backgroundlayout == null)
     {
         Awake();
     }
     manager         = parent;
     current         = choice;
     choiceText.text = choice.choiceDescription;
     Canvas.ForceUpdateCanvases();
     textSize.SetLayoutVertical();
     backgroundlayout.CalculateLayoutInputVertical();
     backgroundSize.SetLayoutVertical();
 }
    public static int CalculateLayoutInputVertical(IntPtr l)
    {
        int result;

        try
        {
            VerticalLayoutGroup verticalLayoutGroup = (VerticalLayoutGroup)LuaObject.checkSelf(l);
            verticalLayoutGroup.CalculateLayoutInputVertical();
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Example #15
0
        private IEnumerator FadeInOut(float toastDuration, float fadeDuration)
        {
            yield return(null);

            uiContentVerticalLayoutGroup.CalculateLayoutInputHorizontal();
            uiContentVerticalLayoutGroup.CalculateLayoutInputVertical();
            uiContentVerticalLayoutGroup.SetLayoutHorizontal();
            uiContentVerticalLayoutGroup.SetLayoutVertical();
            yield return(null);

            // Anim start
            yield return(Fade(uiCanvasGroup, 0f, 1f, fadeDuration));

            yield return(new WaitForSeconds(toastDuration));

            yield return(Fade(uiCanvasGroup, 1f, 0f, fadeDuration));
            // Anim end
        }
Example #16
0
    void Spawn(int count)
    {
        if (transform.childCount > 0)
        {
            //TODO 删除
            UnityHelper.DestoryAllChild(transform);
        }

        for (int idx = 0; idx < count; idx++)
        {
            var clone = GameObject.Instantiate(Prefab) as GameObject;
            clone.transform.SetParent(transform);

            clone.transform.SetLocalPosZ_(0);
            clone.transform.SetLocalScale(Vector3.one);
        }
        //VLayoutGroup.SetLayoutVertical();
        VLayoutGroup.CalculateLayoutInputVertical();
    }
 public void NextLine()
 {
     if (canContinue && activated < dialogues.Count)
     {
         dialogues[activated].Activate(manager);
         //set the empty space to what is was -new text size. gradually grow to only show 1 message
         emptyBlock.sizeDelta = new Vector2(emptyBlock.sizeDelta.x, emptyBlock.sizeDelta.y - dialogues[activated].GetHeight());
         ++activated;
         emptyBlock.SetSiblingIndex(activated);
         Canvas.ForceUpdateCanvases();
         contentLayout.CalculateLayoutInputVertical();
         contentSizeFitter.SetLayoutVertical();
         choiceBox.SetActive(false);
     }
     else if (itemBox.activeSelf == false)
     {
         choiceBox.SetActive(true);
         Canvas.ForceUpdateCanvases();
         choiceLayout.CalculateLayoutInputVertical();
         choiceSizeFitter.SetLayoutVertical();
     }
 }
Example #18
0
        /// <summary>
        /// 部屋一覧を更新する。
        /// </summary>
        /// <returns></returns>
        public async UniTask UpdateRoomListAsync()
        {
            // キャッシュがある場合は、最初に削除しておく
            if (elements.Count > 0)
            {
                elements.ForEach(e => Destroy(e.gameObject));
                elements.Clear();
            }

            view.SetActiveNoRoom(true);

            // サーバと通信して参加可能な部屋一覧を取得する
            var response = await new RoomListApi().Request(new GetRoomList.Request());

            if (response.Result != GetRoomList.Result.Succeed)
            {
                return;
            }

            if (response.RoomDataList.Count < 1)
            {
                return;
            }

            view.SetActiveNoRoom(false);

            // 部屋一覧データを用いてリスト要素を生成する
            foreach (var roomData in response.RoomDataList)
            {
                var element = Instantiate(elementPrefab);
                element.transform.SetParent(layoutGroup.transform);
                element.Initialize(roomData);
                element.OnClickJoinRoomEvent += guid => OnClickJoinRoomEvent?.Invoke(guid);
                elements.Add(element);
            }

            layoutGroup.CalculateLayoutInputVertical();
        }