private void OnBreadcrumbClicked(BreadcrumbData data)
        {
            for (int i = breadcrumbs.Count - 1; i >= 0; i--)
            {
                Breadcrumb breadcrumb = breadcrumbs[i];
                if (breadcrumb.Data == data)
                {
                    break;
                }

                breadcrumbs.RemoveAt(i);
                breadcrumb.AnimateOutAndDestroy();

                if (separators.Count > 0)
                {
                    int        separatorIndex = separators.Count - 1;
                    GameObject separator      = separators[separatorIndex];
                    separators.RemoveAt(separatorIndex);
                    GameObject.Destroy(separator);
                }
            }

            RefreshBreadcrumbs();

            if (OnBreadcrumbChosen != null)
            {
                OnBreadcrumbChosen(data);
            }
        }
        public void AddBreadcrumb(BreadcrumbData breadcrumbData)
        {
            // If this isn't the first breadcrumb, we need to add a separator.
            if (breadcrumbs.Count > 0)
            {
                AddSeparator();
            }

            GameObject breadcrumbObj = GameObject.Instantiate(breadcrumbPrefab);
            Breadcrumb breadcrumb    = breadcrumbObj.GetComponent <Breadcrumb>();

            Assert.IsNotNull(breadcrumb);
            breadcrumb.OnBreadcrumbClicked += OnBreadcrumbClicked;
            breadcrumb.transform.SetParent(breadcrumbContainter, false);
            breadcrumb.Setup(breadcrumbData);
            breadcrumbs.Add(breadcrumb);

            if (breadcrumbs.Count > 1)
            {
                breadcrumb.AnimateIn();
            }

            RefreshBreadcrumbs();
        }
        private void RefreshBreadcrumbs()
        {
            if (breadcrumbs.Count > maxBreadcrumbs)
            {
                if (ellipsis == null)
                {
                    ellipsis = GameObject.Instantiate(ellipsisPrefab);
                    ellipsis.transform.SetParent(breadcrumbContainter, false);
                    Breadcrumb ellipsisCrumb = ellipsis.GetComponent <Breadcrumb>();
                    ellipsisCrumb.AnimateIn();
                }

                // Ellipsis is always the third element.
                // The first element is the first breadcrumb.
                // The second element is the first separator.
                ellipsis.transform.SetSiblingIndex(2);

                for (int i = 1; i < breadcrumbs.Count; i++)
                {
                    Breadcrumb crumb            = breadcrumbs[i];
                    bool       breadcrumbActive = i > breadcrumbs.Count - maxBreadcrumbs + 1;
                    if (breadcrumbActive)
                    {
                        crumb.gameObject.SetActive(true);
                        if (!crumb.IsAnimatedIn && !crumb.IsAnimatingIn)
                        {
                            crumb.AnimateIn();
                        }
                    }
                    else if (!crumb.IsAnimatedOut)
                    {
                        crumb.AnimateOut();
                    }
                }
            }
            else
            {
                if (ellipsis != null)
                {
                    Breadcrumb ellipsisCrumb = ellipsis.GetComponent <Breadcrumb>();
                    ellipsisCrumb.AnimateOutAndDestroy();
                    ellipsis = null;
                }

                for (int i = 0; i < breadcrumbs.Count; i++)
                {
                    Breadcrumb crumb = breadcrumbs[i];
                    crumb.gameObject.SetActive(true);
                    if (!crumb.IsAnimatedIn && !crumb.IsAnimatingIn)
                    {
                        crumb.AnimateIn();
                    }
                }
            }

            for (int i = 0; i < breadcrumbs.Count; i++)
            {
                Breadcrumb crumb = breadcrumbs[i];
                crumb.Refresh(i, breadcrumbs.Count);
            }
        }
        void Awake()
        {
            Breadcrumb breadcrumb = breadcrumbPrefab.GetComponent <Breadcrumb>();

            Assert.IsNotNull(breadcrumb);
        }