/// <summary> /// Remove an item from the graph. /// </summary> /// <param name="item">The settings object to remove</param> public void RemoveItem(GraphItemSettings item) { var idx = _items.FindIndex(x => x.Settings == item); if (idx == -1) { Debug.LogError($"Could not find item {item.name} in graph"); return; } Destroy(_items[idx].Label); Destroy(_items[idx].Line); _items.RemoveAt(idx); }
/// <summary> /// Add an item to the graph. /// </summary> /// <param name="item">A settings object that contains a mixer to read from, a name and colour.</param> public void AddItem(GraphItemSettings item) { var label = Instantiate(LabelPrototype, Labels); var line = Instantiate(LinePrototype, Lines); var newItem = new Item() { Label = label, Line = line, Settings = item }; newItem.SetupItem(); _items.Add(newItem); }