/// <summary> /// Add a child at the end. /// </summary> /// <param name="item"></param> public virtual void AddMenuItem(MenuItem item) { if (!this._items.Contains(item)) { this._items.Add(item); item.Parent = this; } }
/// <summary> /// Insert a child at a specific location. /// </summary> /// <param name="position"></param> /// <param name="item"></param> public virtual void AddMenuItem(int position, MenuItem item) { if (!this._items.Contains(item)) { this._items.Insert(position, item); item.Parent = this; item.transform.SetSiblingIndex(position); } }
/// <summary> /// Remove a child. /// </summary> /// <param name="item"></param> public virtual void RemoveMenuItem(MenuItem item) { if (this._items.Contains(item)) { this._items.Remove(item); item.Parent = null; } }
/// <summary> /// Rearange child order. /// </summary> /// <param name="item"></param> /// <param name="final"></param> public virtual void MoveMenuItem(MenuItem item, int final) { if (this._items.Contains(item)) { this._items.Remove(item); this._items.Insert(final, item); item.transform.SetSiblingIndex(final); } }