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); } }
public void Setup(BreadcrumbData breadcrumbData) { data = breadcrumbData; string truncatedString = breadcrumbData.displayName; nameText.text = truncatedString; }
void Start() { BreadcrumbData breadcrumbData = new BreadcrumbData(); breadcrumbData.displayName = HOME_NAME; breadcrumbData.name = (CurrentNode.value as LevelSelectButtonData).DisplayName; breadcrumbTrail.AddBreadcrumb(breadcrumbData); }
private void OnBreadcrumbChosen(BreadcrumbData data) { AssetTree.Node node = CurrentNode.parent; while (node != null) { LevelSelectButtonData buttonData = node.value as LevelSelectButtonData; if (buttonData.DisplayName == data.name) { CurrentNode = node; break; } node = node.parent; } }
private void OnButtonClicked(LevelSelectButtonData data) { if (!string.IsNullOrEmpty(data.SceneName)) { return; } BreadcrumbData breadcrumbData = new BreadcrumbData(); breadcrumbData.displayName = data.DisplayName; breadcrumbData.name = data.DisplayName; breadcrumbTrail.AddBreadcrumb(breadcrumbData); foreach (AssetTree.Node node in CurrentNode.children) { LevelSelectButtonData nodeData = node.value as LevelSelectButtonData; if (nodeData == data) { CurrentNode = node; break; } } }
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(); }