void ClearOldBuilder()
        {
            if (_viewBuilder != null)
            {
                _viewBuilder.OnRequireUpdateUI  = null;
                _viewBuilder.scrollViewPosition = _scrollView.ScrollPosition;
                _viewBuilder.filterString       = _filterString;
                _viewBuilder.OnPrepareToHide();
            }

            _viewBuilder = null;
        }
        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 void Show(ViewBuilder builder)
        {
            if (builder == null)
            {
                throw new System.Exception("View Builder is null");
            }

            base.Show();

            if (!_isInitialized)
            {
                _isInitialized = true;
                _scrollView.AddCellTemplates(_config.cellTemplates);
                _scrollView.SetDelegate(this);
            }

            ClearOldBuilder();
            SetupNewBuilder(builder);
        }