public unsafe void LateUpdate()
        {
            //IL_00b4: Unknown result type (might be due to invalid IL or missing references)
            //IL_00b9: Unknown result type (might be due to invalid IL or missing references)
            //IL_00c6: Unknown result type (might be due to invalid IL or missing references)
            //IL_00cb: Unknown result type (might be due to invalid IL or missing references)
            //IL_00d8: Unknown result type (might be due to invalid IL or missing references)
            //IL_00e1: Unknown result type (might be due to invalid IL or missing references)
            //IL_00e6: Unknown result type (might be due to invalid IL or missing references)
            //IL_00f3: Unknown result type (might be due to invalid IL or missing references)
            //IL_00fc: Unknown result type (might be due to invalid IL or missing references)
            //IL_0101: Unknown result type (might be due to invalid IL or missing references)
            //IL_010e: Unknown result type (might be due to invalid IL or missing references)
            //IL_011d: Unknown result type (might be due to invalid IL or missing references)
            //IL_0146: Unknown result type (might be due to invalid IL or missing references)
            if (m_opening)
            {
                m_opening = false;
                int num  = 0;
                int num2 = 0;
                switch (m_verticalAlignment)
                {
                case VerticalAlignment.Up:
                    num  = 1;
                    num2 = 1;
                    break;

                case VerticalAlignment.Down:
                    num  = 0;
                    num2 = 0;
                    break;

                default:
                    throw new ArgumentOutOfRangeException("m_verticalAlignment", m_verticalAlignment, null);
                }
                float num3 = 0f;
                float num4 = 0f;
                float num5 = (m_verticalAlignment != 0) ? 1 : (-1);
                for (int i = 0; i < m_activeTooltips.Count; i++)
                {
                    float          num6      = m_nextOpeningDelay * (float)i + m_openingDelay;
                    KeywordTooltip tooltip   = m_activeTooltips[i];
                    RectTransform  component = tooltip.GetComponent <RectTransform>();
                    LayoutRebuilder.ForceRebuildLayoutImmediate(component);
                    Rect    rect   = component.get_rect();
                    float   height = rect.get_height();
                    Vector2 pivot  = component.get_pivot();
                    pivot.y = num;
                    component.set_pivot(pivot);
                    Vector2 val = component.get_anchorMin();
                    val.y = num2;
                    component.set_anchorMin(val);
                    val   = component.get_anchorMax();
                    val.y = num2;
                    component.set_anchorMax(val);
                    component.set_anchoredPosition(new Vector2(0f, num4));
                    tooltip.alpha = 0f;
                    m_openingTweens.Add(TweenSettingsExtensions.SetDelay <Tweener>(DOTweenModuleUI.DOAnchorPos(component, new Vector2(0f, num3), m_openingDuration, false), num6));
                    _003C_003Ec__DisplayClass23_0 _003C_003Ec__DisplayClass23_;
                    m_openingTweens.Add(TweenSettingsExtensions.SetDelay <TweenerCore <float, float, FloatOptions> >(DOTween.To(new DOGetter <float>((object)_003C_003Ec__DisplayClass23_, (IntPtr)(void *) /*OpCode not supported: LdFtn*/), new DOSetter <float>((object)_003C_003Ec__DisplayClass23_, (IntPtr)(void *) /*OpCode not supported: LdFtn*/), 1f, m_openingDuration), num6));
                    num4  = num3;
                    num3 += num5 * (height + m_spacing);
                }
            }
        }
 /// <summary>
 /// See MonoBehaviour.OnValidate.
 /// </summary>
 protected override void OnValidate()
 {
     LayoutRebuilder.MarkLayoutForRebuild(GetComponent <RectTransform>());
 }
Example #3
0
 /// <summary>
 ///   <para>See MonoBehaviour.OnDisable.</para>
 /// </summary>
 protected override void OnDisable()
 {
     m_Tracker.Clear();
     LayoutRebuilder.MarkLayoutForRebuild(rectTransform);
     base.OnDisable();
 }
Example #4
0
        public override void OnInspectorGUI()
        {
            var instance = target as PreferredSizeCopy;

            var copySource = Reflection.GetPrivateField <PreferredSizeCopy, RectTransform>(instance, "copySource");

            EditorGUI.BeginChangeCheck();

            copySource = EditorGUILayout.ObjectField("Source", copySource, typeof(RectTransform), true) as RectTransform;

            if (EditorGUI.EndChangeCheck())
            {
                UnityEditorUtility.RegisterUndo("PreferredSizeCopyEditor-Undo", instance);
                Reflection.SetPrivateField(instance, "copySource", copySource);
            }

            if (copySource != null)
            {
                var horizontal = Reflection.GetPrivateField <PreferredSizeCopy, PreferredSizeCopy.LayoutInfo>(instance, "horizontal");

                if (EditorLayoutTools.Header("Horizontal", "PreferredSizeCopyEditor-Horizontal"))
                {
                    using (new ContentsScope())
                    {
                        var edit = false;

                        EditorGUI.BeginChangeCheck();

                        using (new EditorGUILayout.HorizontalScope())
                        {
                            EditorGUILayout.LabelField("Enable", GUILayout.Width(60f));
                            horizontal.Enable = EditorGUILayout.Toggle(horizontal.Enable);
                        }

                        if (EditorGUI.EndChangeCheck())
                        {
                            edit = true;
                        }

                        using (new DisableScope(!horizontal.Enable))
                        {
                            using (new EditorGUILayout.HorizontalScope())
                            {
                                EditorGUI.BeginChangeCheck();

                                EditorGUILayout.LabelField("Padding", GUILayout.Width(60f));
                                horizontal.Padding = EditorGUILayout.FloatField(horizontal.Padding, GUILayout.Width(100f));

                                if (EditorGUI.EndChangeCheck())
                                {
                                    edit = true;
                                }
                            }

                            using (new EditorGUILayout.HorizontalScope())
                            {
                                EditorGUI.BeginChangeCheck();

                                EditorGUILayout.LabelField("Min", GUILayout.Width(60f));

                                var value  = horizontal.Min.GetValueOrDefault(0f);
                                var enable = EditorGUILayout.Toggle(horizontal.Min.HasValue, GUILayout.Width(30f));

                                if (enable)
                                {
                                    value = EditorGUILayout.FloatField(value, GUILayout.Width(100f));
                                }

                                if (EditorGUI.EndChangeCheck())
                                {
                                    edit           = true;
                                    horizontal.Min = enable ? (float?)value : null;
                                }
                            }

                            using (new EditorGUILayout.HorizontalScope())
                            {
                                EditorGUI.BeginChangeCheck();

                                EditorGUILayout.LabelField("Max", GUILayout.Width(60f));

                                var value  = horizontal.Max.GetValueOrDefault(0f);
                                var enable = EditorGUILayout.Toggle(horizontal.Max.HasValue, GUILayout.Width(30f));

                                if (enable)
                                {
                                    value = EditorGUILayout.FloatField(value, GUILayout.Width(100f));
                                }

                                if (EditorGUI.EndChangeCheck())
                                {
                                    edit           = true;
                                    horizontal.Max = enable ? (float?)value : null;
                                }
                            }

                            using (new EditorGUILayout.HorizontalScope())
                            {
                                EditorGUI.BeginChangeCheck();

                                EditorGUILayout.LabelField("Flexible", GUILayout.Width(60f));

                                var value  = horizontal.Flexible.GetValueOrDefault(0f);
                                var enable = EditorGUILayout.Toggle(horizontal.Flexible.HasValue, GUILayout.Width(30f));

                                if (enable)
                                {
                                    value = EditorGUILayout.FloatField(value, GUILayout.Width(100f));
                                }

                                if (EditorGUI.EndChangeCheck())
                                {
                                    edit = true;
                                    horizontal.Flexible = enable ? (float?)value : null;
                                }
                            }
                        }

                        if (edit)
                        {
                            UnityEditorUtility.RegisterUndo("PreferredSizeCopyEditor-Undo", instance);
                            Reflection.SetPrivateField(instance, "horizontal", horizontal);
                            Reflection.InvokePrivateMethod(instance, "SetDirty");
                        }
                    }
                }

                GUILayout.Space(3f);

                var vertical = Reflection.GetPrivateField <PreferredSizeCopy, PreferredSizeCopy.LayoutInfo>(instance, "vertical");

                if (EditorLayoutTools.Header("Vertical", "PreferredSizeCopyEditor-Vertical"))
                {
                    using (new ContentsScope())
                    {
                        var edit = false;

                        EditorGUI.BeginChangeCheck();

                        using (new EditorGUILayout.HorizontalScope())
                        {
                            EditorGUILayout.LabelField("Enable", GUILayout.Width(60f));
                            vertical.Enable = EditorGUILayout.Toggle(vertical.Enable);
                        }

                        if (EditorGUI.EndChangeCheck())
                        {
                            edit = true;
                        }

                        using (new DisableScope(!vertical.Enable))
                        {
                            using (new EditorGUILayout.HorizontalScope())
                            {
                                EditorGUI.BeginChangeCheck();

                                EditorGUILayout.LabelField("Padding", GUILayout.Width(60f));
                                vertical.Padding = EditorGUILayout.FloatField(vertical.Padding, GUILayout.Width(100f));

                                if (EditorGUI.EndChangeCheck())
                                {
                                    edit = true;
                                }
                            }

                            using (new EditorGUILayout.HorizontalScope())
                            {
                                EditorGUI.BeginChangeCheck();

                                EditorGUILayout.LabelField("Min", GUILayout.Width(60f));

                                var value  = vertical.Min.GetValueOrDefault(0f);
                                var enable = EditorGUILayout.Toggle(vertical.Min.HasValue, GUILayout.Width(30f));

                                if (enable)
                                {
                                    value = EditorGUILayout.FloatField(value, GUILayout.Width(100f));
                                }

                                if (EditorGUI.EndChangeCheck())
                                {
                                    edit         = true;
                                    vertical.Min = enable ? (float?)value : null;
                                }
                            }

                            using (new EditorGUILayout.HorizontalScope())
                            {
                                EditorGUI.BeginChangeCheck();

                                EditorGUILayout.LabelField("Max", GUILayout.Width(60f));

                                var value  = vertical.Max.GetValueOrDefault(0f);
                                var enable = EditorGUILayout.Toggle(vertical.Max.HasValue, GUILayout.Width(30f));

                                if (enable)
                                {
                                    value = EditorGUILayout.FloatField(value, GUILayout.Width(100f));
                                }

                                if (EditorGUI.EndChangeCheck())
                                {
                                    edit         = true;
                                    vertical.Max = enable ? (float?)value : null;
                                }
                            }

                            using (new EditorGUILayout.HorizontalScope())
                            {
                                EditorGUI.BeginChangeCheck();

                                EditorGUILayout.LabelField("Flexible", GUILayout.Width(60f));

                                var value  = vertical.Flexible.GetValueOrDefault(0f);
                                var enable = EditorGUILayout.Toggle(vertical.Flexible.HasValue, GUILayout.Width(30f));

                                if (enable)
                                {
                                    value = EditorGUILayout.FloatField(value, GUILayout.Width(100f));
                                }

                                if (EditorGUI.EndChangeCheck())
                                {
                                    edit = true;
                                    vertical.Flexible = enable ? (float?)value : null;
                                }
                            }
                        }

                        if (edit)
                        {
                            UnityEditorUtility.RegisterUndo("PreferredSizeCopyEditor-Undo", instance);
                            Reflection.SetPrivateField(instance, "vertical", vertical);
                            Reflection.InvokePrivateMethod(instance, "SetDirty");

                            var rt = UnityUtility.GetComponent <RectTransform>(instance.gameObject);
                            LayoutRebuilder.ForceRebuildLayoutImmediate(rt);
                        }
                    }
                }
            }

            EditorGUILayout.Separator();
        }
Example #5
0
 private void UpdateDetailsLayout()
 {
     LayoutRebuilder.ForceRebuildLayoutImmediate(detailsWindow.View.InfoLayout.GetComponent <RectTransform>());
     LayoutRebuilder.ForceRebuildLayoutImmediate(detailsWindow.View.ContentLayout.GetComponent <RectTransform>());
     Canvas.ForceUpdateCanvases();
 }
Example #6
0
 public void UpdateLayouts()
 {
     LayoutRebuilder.ForceRebuildLayoutImmediate(layoutVLab);
 }
 public void RecalcRect()
 {
     _contentSizeFitter.enabled = true;
     LayoutRebuilder.ForceRebuildLayoutImmediate(_rectTransform);
     _contentSizeFitter.enabled = false;
 }
Example #8
0
 public void SetDirty()
 {
     LayoutRebuilder.MarkLayoutForRebuild(this.scoreHeaderContainer);
 }
 void onBarScroll(float value)
 {
     LayoutRebuilder.MarkLayoutForRebuild(rectTransform);
 }
Example #10
0
        /// <summary>
        /// Call this function at any time to update the page collection.
        /// <param name="forceRenewPageNumbers">
        /// If this is set to true, then all pages will be given new page numbers based on their order - if not, only pages which have not yet been issued a pageNumber will be granted one.
        /// The reasoning behind this is that, if this PagedRect is using Infinite Scrolling, then the pages themselves will be reordered as you scroll through them, but we still want
        /// to preserve the page numbers (in the past the order was always the page number).
        /// </param>
        /// </summary>
        public void UpdatePages(bool force = false, bool forceRenewPageNumbers = false, bool updatePagination = true, bool bSetPages = false)
        {
            //if (!AutoDiscoverPages) return;

            if (this == null)
            {
                return;
            }

            if (force)
            {
                this.isDirty = true;
            }

            var tempPages = Viewport.GetComponentsInChildren <Page>(!UsingScrollRect)
                            .Where(p => p != this.NewPageTemplate && p.transform.parent == Viewport.transform && (UsingScrollRect || p.ShowOnPagination))
                            .ToList();

            if (bSetPages)
            {
                _pages = tempPages;
            }
            // avoid an unnecessary initial update (_pages is empty when we initialise)
            if (!_pages.Any())
            {
                _pages = tempPages;
            }
            else
            {
                this.isDirty = this.isDirty || !tempPages.SequenceEqual <Page>(_pages);
            }

            Pages = _pages = tempPages;
            int pageNumber = 1;

            Pages.ForEach(p =>
            {
                if (!p.Initialised)
                {
                    p.Initialise(this);
                }

                if (p.PageNumber == 0 || forceRenewPageNumbers)
                {
                    p.PageNumber = pageNumber;
                }

                if (!ShowPagePreviews)
                {
                    var changed = p.DesiredScale != Vector3.one || (Vector3)p.rectTransform.localScale != Vector3.one;

                    p.DesiredScale             = Vector3.one;
                    p.rectTransform.localScale = Vector3.one;

                    if (changed)
                    {
                        LayoutRebuilder.MarkLayoutForRebuild(p.rectTransform);
                    }
                }

                pageNumber++;
            });

            // see if there are any changes
            if (!this.isDirty)
            {
                return;
            }

            /*if (CurrentPage > NumberOfPages && NumberOfPages > 0)
             * {
             *  //SetCurrentPage(Math.Max(NumberOfPages - 1, 1));
             *  //ShowLastPage();
             * }*/

            if (updatePagination)
            {
                UpdatePagination();
            }
        }
Example #11
0
 void UpdateGfxAgain()
 {
     LayoutRebuilder.ForceRebuildLayoutImmediate(transform.parent.GetComponent <RectTransform> ());
 }
Example #12
0
 public void RebuildLayoutGroup()
 {
     LayoutRebuilder.ForceRebuildLayoutImmediate(layoutRoot);
 }
Example #13
0
    void Start()
    {
        string playerProfilesCsv = SceneData.SelectedPlayerProfiles.Select(it => it.Name).ToCsv();

        Debug.Log($"{playerProfilesCsv} start (or continue) singing of {SongMeta.Title} at {SceneData.PositionInSongInMillis} ms.");

        // Prepare columns and rows for player UI
        PlayerUiArea.SetupPlayerUiGrid(SceneData.SelectedPlayerProfiles.Count, playerUiArea.GetComponent <GridLayoutGroupCellSizer>());

        // Handle players
        List <PlayerProfile> playerProfilesWithoutMic = new List <PlayerProfile>();

        foreach (PlayerProfile playerProfile in SceneData.SelectedPlayerProfiles)
        {
            SceneData.PlayerProfileToMicProfileMap.TryGetValue(playerProfile, out MicProfile micProfile);
            if (micProfile == null)
            {
                playerProfilesWithoutMic.Add(playerProfile);
            }
            PlayerController playerController = CreatePlayerController(playerProfile, micProfile);

            if (SceneData.PlayerProfileToScoreDataMap.TryGetValue(playerProfile, out PlayerScoreControllerData scoreData))
            {
                playerController.PlayerScoreController.ScoreData = scoreData;
            }
        }

        // Handle dummy singers
        if (Application.isEditor)
        {
            DummySingers = FindObjectsOfType <AbstractDummySinger>().ToList();
            foreach (AbstractDummySinger dummySinger in DummySingers)
            {
                if (dummySinger.playerIndexToSimulate < PlayerControllers.Count)
                {
                    dummySinger.SetPlayerController(PlayerControllers[dummySinger.playerIndexToSimulate]);
                }
                else
                {
                    Debug.LogWarning("DummySinger cannot simulate player with index " + dummySinger.playerIndexToSimulate);
                    dummySinger.gameObject.SetActive(false);
                }
            }
        }

        // Create warning about missing microphones
        string playerNameCsv = string.Join(",", playerProfilesWithoutMic.Select(it => it.Name).ToList());

        if (!playerProfilesWithoutMic.IsNullOrEmpty())
        {
            UiManager.Instance.CreateWarningDialog(
                I18NManager.GetTranslation(R.String.singScene_missingMicrophones_title),
                I18NManager.GetTranslation(R.String.singScene_missingMicrophones_message, "playerNameCsv", playerNameCsv));
        }

        // Associate LyricsDisplayer with one of the (duett) players
        InitLyricsDisplayers();

        //Save information about the song being started into stats
        Statistics stats = StatsManager.Instance.Statistics;

        stats.RecordSongStarted(SongMeta);

        songVideoPlayer.Init(SongMeta, songAudioPlayer);

        StartCoroutine(StartMusicAndVideo());

        // Rebuild whole UI
        LayoutRebuilder.ForceRebuildLayoutImmediate(CanvasUtils.FindCanvas().GetComponent <RectTransform>());
    }
Example #14
0
 public void TriggerRefresh()
 {
     LayoutRebuilder.ForceRebuildLayoutImmediate(LayoutGroup);
 }
Example #15
0
 public void DirtyNow()
 {
     LayoutRebuilder.MarkLayoutForRebuild(this.root);
 }
Example #16
0
 void Execute()
 {
     LayoutRebuilder.ForceRebuildLayoutImmediate(transform as RectTransform);
 }
Example #17
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.PropertyField(m_SourceRectTransform);
            EditorGUILayout.PropertyField(m_ValuesArePercentage);

            if (m_ValuesArePercentage.boolValue)
            {
                using (new GUILayout.HorizontalScope())
                {
                    EditorGUILayout.PrefixLabel("Padding Percent");
                    EditorGUILayout.LabelField("X", GUILayout.MaxWidth(12));
                    EditorGUILayout.PropertyField(m_SnapWidth, GUIContent.none, GUILayout.MaxWidth(14));

                    GUI.enabled = m_SnapWidth.boolValue;
                    EditorGUILayout.PropertyField(m_PaddingPercent.FindPropertyRelative("x"), GUIContent.none);
                    GUI.enabled = true;

                    EditorGUILayout.LabelField("Y", GUILayout.MaxWidth(12));
                    EditorGUILayout.PropertyField(m_SnapHeight, GUIContent.none, GUILayout.MaxWidth(14));

                    GUI.enabled = m_SnapHeight.boolValue;
                    EditorGUILayout.PropertyField(m_PaddingPercent.FindPropertyRelative("y"), GUIContent.none);
                    GUI.enabled = true;
                }

                using (new GUILayout.HorizontalScope())
                {
                    EditorGUILayout.PrefixLabel("Offset Percent");
                    EditorGUILayout.LabelField("X", GUILayout.MaxWidth(12));
                    EditorGUILayout.PropertyField(m_SnapPositionX, GUIContent.none, GUILayout.MaxWidth(14));

                    GUI.enabled = m_SnapPositionX.boolValue;
                    EditorGUILayout.PropertyField(m_OffsetPercent.FindPropertyRelative("x"), GUIContent.none);
                    GUI.enabled = true;

                    EditorGUILayout.LabelField("Y", GUILayout.MaxWidth(12));
                    EditorGUILayout.PropertyField(m_SnapPositionY, GUIContent.none, GUILayout.MaxWidth(14));

                    GUI.enabled = m_SnapPositionY.boolValue;
                    EditorGUILayout.PropertyField(m_OffsetPercent.FindPropertyRelative("y"), GUIContent.none);
                    GUI.enabled = true;
                }
            }
            else
            {
                using (new GUILayout.HorizontalScope())
                {
                    EditorGUILayout.PrefixLabel("Padding");
                    EditorGUILayout.LabelField("X", GUILayout.MaxWidth(12));
                    EditorGUILayout.PropertyField(m_SnapWidth, GUIContent.none, GUILayout.MaxWidth(14));

                    GUI.enabled = m_SnapWidth.boolValue;
                    EditorGUILayout.PropertyField(m_Padding.FindPropertyRelative("x"), GUIContent.none);
                    GUI.enabled = true;

                    EditorGUILayout.LabelField("Y", GUILayout.MaxWidth(12));
                    EditorGUILayout.PropertyField(m_SnapHeight, GUIContent.none, GUILayout.MaxWidth(14));

                    GUI.enabled = m_SnapHeight.boolValue;
                    EditorGUILayout.PropertyField(m_Padding.FindPropertyRelative("y"), GUIContent.none);
                    GUI.enabled = true;
                }

                using (new GUILayout.HorizontalScope())
                {
                    EditorGUILayout.PrefixLabel("Offset");
                    EditorGUILayout.LabelField("X", GUILayout.MaxWidth(12));
                    EditorGUILayout.PropertyField(m_SnapPositionX, GUIContent.none, GUILayout.MaxWidth(14));

                    GUI.enabled = m_SnapPositionX.boolValue;
                    EditorGUILayout.PropertyField(m_Offset.FindPropertyRelative("x"), GUIContent.none);
                    GUI.enabled = true;

                    EditorGUILayout.LabelField("Y", GUILayout.MaxWidth(12));
                    EditorGUILayout.PropertyField(m_SnapPositionY, GUIContent.none, GUILayout.MaxWidth(14));

                    GUI.enabled = m_SnapPositionY.boolValue;
                    EditorGUILayout.PropertyField(m_Offset.FindPropertyRelative("y"), GUIContent.none);
                    GUI.enabled = true;
                }
            }

            EditorGUILayout.PropertyField(m_SnapEveryFrame);

            serializedObject.ApplyModifiedProperties();

            if (GUILayout.Button("Snap"))
            {
                LayoutRebuilder.MarkLayoutForRebuild(((RectTransformSnap)target).rectTransform);
                EditorUtility.SetDirty(serializedObject.targetObject);
            }
        }
            private static void ListUpdate(CustomSelectListCtrl __instance)
            {
                if (!_listCache.TryGetValue(__instance, out var listData))
                {
                    return;
                }

                var scrollPosition = listData.ScrollPositionY;
                // How many items are not visible in current view
                var visibleItemCount   = listData.ItemList.Count(x => !x.disvisible);
                var offscreenItemCount = Mathf.Max(0, visibleItemCount - listData.ItemCache.Count);
                // How many items are above current view rect and not visible
                var rowsAboveViewRect  = Mathf.FloorToInt(Mathf.Clamp(scrollPosition / listData.ItemHeight, 0, offscreenItemCount));
                var itemsAboveViewRect = rowsAboveViewRect * listData.ItemsInRow;

                if (listData.LastItemsAbove == itemsAboveViewRect && !listData.IsDirty)
                {
                    return;
                }

                listData.LastItemsAbove = itemsAboveViewRect;
                listData.IsDirty        = false;

                // Store selected item to preserve selection when moving the list with mouse
                var selectedItem = listData.ItemList.Find(x => x.sic != null && x.sic.gameObject == EventSystem.current.currentSelectedGameObject);

                listData.ItemList.ForEach(x => x.sic = null);
                // Apply visible list items to actual cache items
                var count = 0;

                foreach (var item in listData.ItemList.Where(x => !x.disvisible).Skip(itemsAboveViewRect))
                {
                    if (count >= listData.ItemCache.Count)
                    {
                        break;
                    }

                    var cachedEntry = listData.ItemCache[count];

                    count++;

                    cachedEntry.info = item;
                    item.sic         = cachedEntry;

                    cachedEntry.Disable(item.disable);

                    cachedEntry.objNew.SetActiveIfDifferent(VirtualListData.IsItemNew(item));

                    var thumb = listData.GetThumbSprite(item);
                    cachedEntry.img.sprite = thumb;

                    if (ReferenceEquals(selectedItem, item))
                    {
                        EventSystem.current.SetSelectedGameObject(cachedEntry.gameObject);
                    }

                    cachedEntry.gameObject.SetActiveIfDifferent(true);
                }

                // Disable unused cache items
                if (count < listData.ItemCache.Count)
                {
                    foreach (var cacheEntry in listData.ItemCache.Skip(count))
                    {
                        cacheEntry.gameObject.SetActiveIfDifferent(false);
                    }
                }

                listData.UpdateSelection();

                // Apply top and bottom offsets to create the illusion of having all of the list items
                var topOffset = Mathf.RoundToInt(rowsAboveViewRect * listData.ItemHeight);

                listData.LayoutGroup.padding.top = listData.InitialTopPadding + topOffset;

                var totalHeight        = Mathf.CeilToInt((float)visibleItemCount / listData.ItemsInRow) * listData.ItemHeight;
                var cacheEntriesHeight = Mathf.CeilToInt((float)listData.ItemCache.Count / listData.ItemsInRow) * listData.ItemHeight;
                var trailingHeight     = totalHeight - cacheEntriesHeight - topOffset;

                listData.LayoutGroup.padding.bottom = Mathf.FloorToInt(Mathf.Max(0, trailingHeight) + listData.InitialBotPadding);

                // Needed after changing padding since it doesn't make the object dirty
                LayoutRebuilder.MarkLayoutForRebuild(listData.Content);
            }
Example #19
0
 private void RefreshCanvas()
 {
     LayoutRebuilder.ForceRebuildLayoutImmediate(GetComponent <RectTransform>());
     Canvas.ForceUpdateCanvases();
 }
Example #20
0
        private void Awake()
        {
            columns = _GetHeaderElements();

            if (sortings.Count > 0)
            {
                sortings.Clear();
            }

            columns.ForEach(h => sortings.Add(false));

            for (int i = 0; i < columns.Count; i++)
            {
                int id = i;
                DataGridViewColumn column = columns[id];

                if (column.sizeScaler != null)
                {
                    column.sizeScaler.scaleChanged.AddListener(size =>
                    {
                        uiRows.ForEach(r =>
                        {
                            RectTransform cellRT = r.cells[id].GetComponent <RectTransform>();
                            cellRT.sizeDelta     = new Vector2(size.x, cellRT.sizeDelta.y);
                            LayoutRebuilder.ForceRebuildLayoutImmediate(r.GetComponent <RectTransform>());
                        });
                    });
                }

                Button headerButton = column.GetComponent <Button>();

                headerButton.onClick.AddListener(() =>
                {
                    bool sorting = sortings[id];

                    rows.Sort((a, b) => {
                        string firstString  = a.cells[id].value;
                        string secondString = b.cells[id].value;

                        int first;
                        int second;

                        if (Int32.TryParse(firstString, out first) && Int32.TryParse(secondString, out second))
                        {
                            return(first.CompareTo(second));
                        }

                        return(firstString.CompareTo(secondString));
                    });


                    if (sorting)
                    {
                        rows.Reverse();
                    }

                    sortings     = sortings.Select(x => false).ToList();
                    sortings[id] = sorting ? false : true;

                    rows.changed?.Invoke();
                });
            }

            rows.changed.AddListener(OnChange);
        }
Example #21
0
        IEnumerator UpdateIndicatorLayout()
        {
            yield return(new WaitForSeconds(0.1f));

            LayoutRebuilder.ForceRebuildLayoutImmediate(indicatorParent.GetComponentInParent <RectTransform>());
        }
Example #22
0
 /// <summary>
 /// Unlocks the layout, allowing it to again dynamically resize when component sizes
 /// are changed.
 /// </summary>
 public virtual void UnlockLayout()
 {
     locked = false;
     LayoutRebuilder.MarkLayoutForRebuild(gameObject.rectTransform());
 }
Example #23
0
    public void SetTip(SOTip tip)
    {
        ResetImagePasePanel();

        if (tip.IsLocalisedText)
        {
            tipsText.text = Localization.GetString(tip.TipText);
        }
        else
        {
            tipsText.text = tip.TipText;
        }

        //
        tipsImagePlace.gameObject.SetActive(true);

        if (tip.AnimatedImageOriginal != null)
        {
            SetAnimatedImage(tip.AnimatedImageOriginal);
        }
        else if (tip.Images.Length > 0)
        {
            foreach (var img in tip.Images)
            {
                SetImage(img, tip.Direction);
            }
            LayoutRebuilder.MarkLayoutForRebuild(tipsImagePlace);
        }
        else
        {
            tipsImagePlace.gameObject.SetActive(false);
        }


        if (tip.Direction == SOTip.Directions.HORISONTAL)
        {
            var layout = horisontalLayout;
            ResetTipPanelLayout(layout);

            layout.childAlignment         = TextAnchor.MiddleCenter;
            layout.spacing                = 20;
            layout.padding.left           = 100;
            layout.padding.right          = 100;
            layout.childControlHeight     = true;
            layout.childControlWidth      = true;
            layout.childForceExpandHeight = true;
            layout.childForceExpandWidth  = true;

            tipsText.alignment = TextAlignmentOptions.Midline;
        }
        else
        {
            var layout = vertialLayout;
            ResetTipPanelLayout(layout);

            layout.childAlignment         = TextAnchor.MiddleCenter;
            layout.spacing                = 10;
            layout.childControlHeight     = true;
            layout.childControlWidth      = true;
            layout.childForceExpandHeight = true;
            layout.childForceExpandWidth  = true;

            tipsText.alignment = TextAlignmentOptions.Midline;
        }
    }
Example #24
0
        /// <summary>
        /// Sets an object's layout dirty on the next frame.
        /// </summary>
        /// <param name="transform">The transform to set dirty.</param>
        /// <returns>A coroutine to set it dirty.</returns>
        internal static IEnumerator DelayedSetDirty(RectTransform transform)
        {
            yield return(null);

            LayoutRebuilder.MarkLayoutForRebuild(transform);
        }
Example #25
0
    // Reminder since I keep forgetting: The UI must be built while in play mode for the buttons to work
    public void BuildUI()
    {
        if (testUI)
        {
            return;
        }

        treeItems = new List <TreeView.TreeItem> ();
        foreach (var item in testTreeItems)
        {
            treeItems.Add(new TreeView.TreeItem(item, i => (i as TestTreeItem).Name, i => (i as TestTreeItem).Count != 0, 0));
        }

        Window basePanel = UIKit.CreateUI <Window>(appCanvas.transform as RectTransform, "testUI");

        testUI = basePanel.gameObject;

        basePanel
        .Title("A test")
        .Vertical()
        .ControlChildSize(true, true)
        .ChildForceExpand(false, false)
        .PreferredSizeFitter(true, true)
        .Anchor(AnchorPresets.MiddleCenter)
        .Pivot(PivotPresets.TopLeft)
        .PreferredWidth(300)
        .Add <UIButton>()
        .Text("Button A")
        .OnClick(ButtonAction)
        .FlexibleLayout(true, false)
        .Finish()
        .Add <Layout>()
        .Horizontal()
        .ControlChildSize(true, true)
        .ChildForceExpand(false, false)
        .Anchor(AnchorPresets.HorStretchTop)
        .FlexibleLayout(true, false)
        .Add <UIEmpty>()
        .FlexibleLayout(true, true)
        .Finish()
        .Add <UIButton>()
        .Text("B")
        .OnClick(ButtonAction)
        .Finish()
        .Add <UIEmpty>()
        .FlexibleLayout(true, true)
        .Finish()
        .Add <UIButton>()
        .Text("C")
        .OnClick(ButtonAction)
        .Finish()
        .Add <UIEmpty>()
        .FlexibleLayout(true, true)
        .Finish()
        .Add <UIButton>()
        .Image(SpriteLoader.GetSprite("KodeUI/Default/toggle_on"))
        .OnClick(ButtonAction)
        .Finish()
        .Finish()
        .Add <Layout>()
        .Horizontal()
        .ControlChildSize(true, true)
        .ChildForceExpand(false, false)
        .Anchor(AnchorPresets.HorStretchTop)
        .FlexibleLayout(true, false)
        .Add <UIButton>()
        .Text("Very Long text")
        .OnClick(ButtonAction)
        .FlexibleLayout(true, false)
        .Finish()
        .Add <UIEmpty>()
        .FlexibleLayout(true, true)
        .Finish()
        .Add <UIButton>()
        .Text("Is Long")
        .OnClick(ButtonAction)
        .FlexibleLayout(true, false)
        .Finish()
        .Finish()
        .Add <UIText>()
        .Text("A long text that should overflow to the next line")
        .Alignment(TextAlignmentOptions.TopLeft)
        .FlexibleLayout(true, false)
        .Finish()

        .Add <Layout>()
        .Horizontal()
        .ControlChildSize(true, true)
        .ChildForceExpand(false, false)
        .Anchor(AnchorPresets.HorStretchTop)
        .Add <UIText>(out text)
        .Text("N/A")
        .Alignment(TextAlignmentOptions.TopLeft)
        .FlexibleLayout(true, false)
        .Finish()
        .Finish()

        .Add <UIToggle>()
        .OnValueChanged(Action)
        .FlexibleLayout(false, true)
        .PreferredSize(15, 15)
        .Finish()
        .Add <UIInputField>()
        .FlexibleLayout(true, false)
        .SizeDelta(0, 0)
        .Finish()
        .Add <TreeView>(out treeView)
        .Items(treeItems)
        .OnClick(OnTreeClicked)
        .OnStateChanged(OnTreeStateChanged)
        .PreferredSize(-1, 150)
        .FlexibleLayout(true, true)
        .Finish()
        .Finish();


        // needed in the editor to have the proper layout when not in play mode
        LayoutRebuilder.ForceRebuildLayoutImmediate(basePanel.rectTransform);


        // TODO:
        // * LayoutElement sur tout ? Flexible  Size H/V en fonction du layout parent ?
        // * ContentSizeFitter sur tout/certain ? H/V en fonction du layout parent ?
    }
        private IEnumerator InitCoroutine()
        {
            yield return(null);

            LayoutRebuilder.ForceRebuildLayoutImmediate(InspectorPanel.Instance.ContentRect);
        }
Example #27
0
 private void OnCanvasChanged(bool scaleChanged, bool orientationChanged)
 {
     LayoutRebuilder.ForceRebuildLayoutImmediate(rectTransform);
     OnSliderValueChanged(slider.value);
 }
Example #28
0
    /// <summary>
    /// Draw this piece of the UI
    /// </summary>
    private void SetUp()
    {
        //set UI to display differently if certain attributes are set
        if (_attributeDict.ContainsKey("part" + _currentText))
        {
            if (_attributeDict["part" + _currentText].Contains("mood"))
            {
                UIManagement.CrewMemberUI.ToList().ForEach(c => c.ForcedMoodChange(_attributeDict["part" + _currentText].Replace("mood-", string.Empty)));
            }
            if (_attributeDict["part" + _currentText].Contains("opinion"))
            {
                UIManagement.MemberMeeting.DisplayOpinions(_attributeDict["part" + _currentText].Replace("opinion-", string.Empty) == "accurate");
            }
        }
        _reverseRaycast.MaskRect.Clear();
        _reverseRaycast.MaskRect.Add(_menuHighlighted);
        //set which objects should be highlighted and blocked from interactions
        if (_tutorialObj.HighlightedObject[_currentText].Length > 0)
        {
            _softMaskScript.FlipAlphaMask = false;
            var anchorObject = UIManagement.Canvas.transform.Find(_tutorialObj.HighlightedObject[_currentText]).RectTransform() ?? UIManagement.Canvas.RectTransform();
            _softMaskScript.maskScalingRect = anchorObject;
            _reverseRaycast.MaskRect.Add(anchorObject);
        }
        else
        {
            _softMaskScript.FlipAlphaMask   = true;
            _softMaskScript.maskScalingRect = null;
        }

        if (_tutorialObj.BlacklistButtons[_currentText] != null)
        {
            var blacklistButtons = _tutorialObj.BlacklistButtons[_currentText].List.Select(blb => _reverseRaycast.MaskRect[1].FindAll(blb)).SelectMany(x => x).Where(x => x.GetComponent <Selectable>()).Select(x => x.RectTransform()).ToList();
            _reverseRaycast.BlacklistRect.Clear();
            _reverseRaycast.BlacklistRect.AddRange(blacklistButtons);
            var whiteList = new List <RectTransform>(_reverseRaycast.MaskRect);
            whiteList.RemoveAt(0);
            foreach (var trans in whiteList)
            {
                if (!trans.GetComponent <Canvas>())
                {
                    _reverseRaycast.BlacklistRect.Add(trans);
                }
            }
        }
        //display different object if it is the last part of the tutorial
        if (UIManagement.Tutorial.SectionCount == GameManagement.TutorialStage + 1)
        {
            transform.FindObject("Tutorial Helper").Active(false);
            _tutorialText.text = _sectionText[Localization.SelectedLanguage.Name][_currentText];
        }
        else
        {
            //draw UI differently according to if the side displaying the helper is reversed
            transform.localScale = _tutorialObj.ShowOnLeft ? new Vector2(-1, 1) : Vector2.one;
            _tutorialText.transform.localScale = _tutorialObj.ShowOnLeft ? new Vector2(-1, 1) : Vector2.one;
            _buttons.transform.localScale      = _tutorialObj.ShowOnLeft ? new Vector2(-1, 1) : Vector2.one;

            var mhMin = _menuHighlighted.anchorMin.x;
            if ((_tutorialObj.ShowOnLeft && mhMin < 0) || (!_tutorialObj.ShowOnLeft && mhMin > 0))
            {
                var mhMax = _menuHighlighted.anchorMax.x;
                _menuHighlighted.anchorMin = new Vector2(1 - mhMax, _menuHighlighted.anchorMin.y);
                _menuHighlighted.anchorMax = new Vector2(1 - mhMin, _menuHighlighted.anchorMax.y);
            }
            GetComponentInChildren <LayoutGroup>().childAlignment = _tutorialObj.ShowOnLeft ? TextAnchor.UpperRight : TextAnchor.UpperLeft;

            var pageNumber = _buttons.FindText("Page Number");
            //if text is provided, display the tutorial helper
            if (_sectionText[Localization.SelectedLanguage.Name].Count == 0)
            {
                _tutorialObject.Active(false);
                _reverseRaycast.UnblockWhitelisted();
                pageNumber.text = string.Empty;
            }
            else
            {
                //display different buttons and sections according to what oart should be displayed
                _tutorialObject.Active(true);
                _tutorialText.text = _sectionText[Localization.SelectedLanguage.Name][_currentText];
                _buttons.FindObject("Back").Active(_currentText != 0);
                var lastPage = _currentText == _sectionText[Localization.SelectedLanguage.Name].Count - 1;
                _buttons.FindObject("Forward").Active(!lastPage);
                if (lastPage)
                {
                    _reverseRaycast.UnblockWhitelisted();
                    _unblocked = true;
                }
                pageNumber.text = _sectionText[Localization.SelectedLanguage.Name].Count == 1 ? string.Empty : _currentText + 1 + "/" + _sectionText[Localization.SelectedLanguage.Name].Count;
            }
            var showProgress = _tutorialObj.EventTriggerCountRequired > 1 && _unblocked;
            _buttons.FindText("Progress Count").text = showProgress ? (_tutorialObj.EventTriggerCountRequired - _eventTriggerCount).ToString() : string.Empty;
            pageNumber.RectTransform().anchorMin = showProgress ? new Vector2(0.375f, 0) : new Vector2(0.45f, 0);
            pageNumber.RectTransform().anchorMax = showProgress ? new Vector2(0.575f, 1) : new Vector2(0.65f, 1);
        }
        LayoutRebuilder.ForceRebuildLayoutImmediate(_tutorialObject.transform.FindRect("Image"));
    }
 /// <summary>
 /// Marks the button's layout to be rebuilt in the next layout calculation.
 /// </summary>
 public void SetLayoutDirty()
 {
     LayoutRebuilder.MarkLayoutForRebuild(rectTransform);
 }
Example #30
0
        private IEnumerator LoadRatingCoroutine(bool submit)
        {
            yield return(null);

            Wheel.SetActive(true);
            LevelRatingText.gameObject.SetActive(false);

            MessageText.gameObject.SetActive(true);
            MessageText.text = submit ? "Updating level rating..." : "Loading level rating...";
            Stars.gameObject.SetActive(false);
            RateButton.gameObject.GetComponent <UIButton>().enabled = false;
            RateButton.gameObject.SetActive(false);

            yield return(OnlinePlayer.Rate(new RateData
            {
                user = OnlinePlayer.Name,
                password = OnlinePlayer.Password,
                level = CytoidApplication.CurrentLevel.id,
                player_rating = submit ? Stars.Rating : -1
            }));

            var result = OnlinePlayer.LastRateResult;

            if (result.status == -1)
            {
                MessageText.text     = "Could not fetch level ratings.";
                LevelRatingText.text = "N/A";
                Wheel.SetActive(false);
                LevelRatingText.gameObject.SetActive(true);
                LayoutRebuilder.ForceRebuildLayoutImmediate(GetComponent <RectTransform>());
                failed = true;
                yield break;
            }

            Wheel.SetActive(false);
            LevelRatingText.gameObject.SetActive(true);

            if (result.total == 0)
            {
                LevelRatingText.text = "N/A";
            }
            else
            {
                LevelRatingText.text = string.Format("{0:0.00} ({1})", result.average_rating, result.total);
            }

            Stars.gameObject.SetActive(true);

            if (result.player_rating != -1)
            {
                Stars.Rating     = result.player_rating;
                MessageText.text = string.Format("You rated {0:0.#}/5.", Mathf.FloorToInt(result.player_rating * 2) / 2f);
            }
            else
            {
                if (result.total == 0)
                {
                    MessageText.text = "Not rated yet.\nBe the first!";
                }
                else
                {
                    MessageText.text = "Rate this level!";
                }

                if (ScoreGrades.From((float)CytoidApplication.CurrentPlay.Score) >= ScoreGrade.A)
                {
                    UIManager.GetUiElements("RateWindow")[0].Show(false);
                }
            }

            RateButton.gameObject.SetActive(true);
            RateButton.gameObject.GetComponent <UIButton>().enabled = true;
            RateButton.transform.SetAsLastSibling();

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