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); } }
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); } }