public static void CreateOrUpdateItem(this ToolbarBreadcrumbs breadcrumbs, int index, string itemLabel, Action clickedEvent) { if (index >= breadcrumbs.childCount) { breadcrumbs.PushItem(itemLabel, clickedEvent); } else { if (breadcrumbs.ElementAt(index) is ToolbarButton item) { item.text = itemLabel; item.ChangeClickEvent(clickedEvent); } else { Debug.LogError("Trying to update an element that is not a ToolbarButton"); } } }
public static void CreateOrUpdateItem(this ToolbarBreadcrumbs breadcrumbs, int index, string itemLabel, Action <int> clickedEvent) { if (index >= breadcrumbs.childCount) { breadcrumbs.PushItem(itemLabel, () => { int i = index; clickedEvent?.Invoke(i); }); } else { if (breadcrumbs.ElementAt(index) is ToolbarButton item) { item.text = itemLabel; } else { Debug.LogError("Trying to update an element that is not a ToolbarButton"); } } }