void SetupNewBuilder(ViewBuilder builder)
        {
            // Prevent input filter callback while we set its value
            _isPreparingView = true;

            _viewBuilder = builder;
            _viewBuilder.OnRequireUpdateUI = OnUpdateView;
            _viewBuilder.OnPrepareToShow();

            // Update title
            bool hasTitle = !string.IsNullOrEmpty(_viewBuilder.title);

            _title.gameObject.SetActive(hasTitle);
            if (hasTitle)
            {
                _title.text = _viewBuilder.title;
            }

            // Update filter string
            _filterString      = _viewBuilder.filterString;
            _inputFilter.input = _filterString;
            _filterGroup.SetActive(!hasTitle);

            // Update buttons
            _backButton.SetActive(_viewBuilder.level > 0);
            _actionButton.SetActive(_viewBuilder.actionButtonCallback != null);
            AssetConfig.SpriteInfo spriteInfo = _config.GetSpriteInfo(_viewBuilder.actionButtonIcon);
            if (spriteInfo != null)
            {
                UnityEngine.UI.Image buttonImage = _actionButton.GetComponentInChildren <UnityEngine.UI.Image>();
                buttonImage.sprite = spriteInfo.sprite;
                buttonImage.color  = spriteInfo.color;
            }

            // Rebuild the whole tree
            _viewBuilder.Rebuild();

            // Update scroll view
            if (!_viewBuilder.saveScrollViewPosition)
            {
                _scrollView.MoveViewToTop();
            }
            else
            {
                _scrollView.ScrollPosition = _viewBuilder.scrollViewPosition;
            }

            _isPreparingView = false;
        }
        public override ScrollViewCell CreateCell(RecycleScrollView scrollView, AssetConfig config, int cellIndex)
        {
            BaseGenericCell cell = (BaseGenericCell)scrollView.CreateCell(CellIdentifier());

            cell.SetText(DisplayText);
            cell.SetHeaderOffset(LogConsoleSettings.GetTreeViewOffsetByLevel(level));
            cell.SetBackgroundColor(LogConsoleSettings.GetCellColor(cellIndex));

            AssetConfig.SpriteInfo spriteInfo = config.GetSpriteInfo(icon);
            if (spriteInfo != null)
            {
                cell.SetIcon(spriteInfo.sprite);
                cell.SetIconColor(iconColor != Color.white ? iconColor : spriteInfo.color);
            }
            else
            {
                cell.SetIcon(null);
            }


            return(cell);
        }
        public override ScrollViewCell CreateCell(RecycleScrollView scrollView, AssetConfig config, int cellIndex)
        {
            string          cellId = resizable ? "GenericResizableCell" : "GenericCell";
            BaseGenericCell cell   = (BaseGenericCell)scrollView.CreateCell(cellId);

            cell.SetText(DisplayText);
            cell.SetHeaderOffset(LogConsoleSettings.GetTreeViewOffsetByLevel(level));
            cell.SetBackgroundColor(LogConsoleSettings.GetCellColor(cellIndex));

            AssetConfig.SpriteInfo spriteInfo = config.GetSpriteInfo((isExpanded || string.IsNullOrEmpty(iconClose)) ? icon : iconClose);
            if (spriteInfo != null)
            {
                cell.SetIcon(spriteInfo.sprite);
                cell.SetIconColor(iconColor != Color.white ? iconColor : spriteInfo.color);
            }
            else
            {
                cell.SetIcon(null);
            }

            return(cell);
        }
Example #4
0
        void UpdateCell(ScrollViewCell cell)
        {
            BaseLogCell logCell = cell as BaseLogCell;
            LogInfo     logInfo = _filterLogInfos[logCell.info.index];

            AssetConfig.SpriteInfo iconConfig = _assetConfig.GetSpriteInfo(LogTypeToIconName(logInfo.type));
            logCell.SetIcon(iconConfig.sprite);
            logCell.SetIconColor(iconConfig.color);
            logCell.SetBackgroundColor(LogConsoleSettings.GetCellColor(logCell.info.index));

            _cachedText.Length = 0;

            if (LogConsoleSettings.Instance.showTimestamp)
            {
                _cachedText.Append(logInfo.time);
            }

            if (LogConsoleSettings.Instance.showLogChannel && logInfo.channelInfo != null)
            {
                _cachedText.Append(logInfo.channelInfo.nameWithColor);
                _cachedText.Append("  ");
            }

            _cachedText.Append(logInfo.shortMessage);
            logCell.SetText(_cachedText.ToString());

            if (LogFilter.Instance.IsCollapse)
            {
                logCell.SetCollapseEnable(true);
                logCell.SetCollapseNumber(logInfo.numInstance);
            }
            else
            {
                logCell.SetCollapseEnable(false);
            }
        }