예제 #1
0
        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);
                }
            }

            for (int i = 0; i < breadcrumbs.Count; i++)
            {
                Breadcrumb crumb = breadcrumbs[i];
                crumb.Refresh(i, breadcrumbs.Count);
            }

            if (OnBreadcrumbChosen != null)
            {
                OnBreadcrumbChosen(data);
            }
        }
예제 #2
0
        private void RefreshBreadcrumbs()
        {
            if (breadcrumbs.Count > maxBreadcrumbs)
            {
                if (ellipsis == null)
                {
                    ellipsis = GameObject.Instantiate(ellipsisPrefab);
                    ellipsis.transform.SetParent(breadcrumbContainter, false);
                }

                // 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++)
                {
                    bool breadcrumbActive = i > breadcrumbs.Count - maxBreadcrumbs + 1;
                    breadcrumbs[i].gameObject.SetActive(breadcrumbActive);
                }
            }
            else
            {
                if (ellipsis != null)
                {
                    Destroy(ellipsis);
                    ellipsis = null;
                }

                for (int i = 0; i < breadcrumbs.Count; i++)
                {
                    breadcrumbs[i].gameObject.SetActive(true);
                }
            }

            for (int i = 0; i < breadcrumbs.Count; i++)
            {
                Breadcrumb crumb = breadcrumbs[i];
                crumb.Refresh(i, breadcrumbs.Count);
            }
        }
예제 #3
0
        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();
        }
예제 #4
0
        void Awake()
        {
            Breadcrumb breadcrumb = breadcrumbPrefab.GetComponent <Breadcrumb>();

            Assert.IsNotNull(breadcrumb);
        }