/// <summary> /// Return all tags in the specific GameObject /// </summary> /// <param name = "value">The specific gameobject</param> public static List <Tags> ReturnTags(this GameObject value) { Debug.Assert(value != null); MultiTags CurrentMultiTagsComponent = value.GetComponent <MultiTags>(); if (CurrentMultiTagsComponent == null || CurrentMultiTagsComponent.tags.Count < 0) { return(null); } return(CurrentMultiTagsComponent.tags); }
/// <summary> /// Are there tags in this GameObject? /// </summary> /// <param name = "value">The gameobject</param> /// <param name = "tagsParameter">The tags that must have the GameObject</param> public static bool HaveTags(this GameObject value, params Tags[] tagsParameter) { Debug.Assert(value != null && tagsParameter != null); MultiTags CurrentMultiTagsComponent = value.GetComponent <MultiTags>(); if (CurrentMultiTagsComponent == null) { return(!(tagsParameter.Length > 0)); } return(AreThereTagsInList(CurrentMultiTagsComponent.tags, tagsParameter)); }
/// <summary> /// Add these tags in the specific GameObject /// </summary> /// <param name = "value">The specific gameobject</param> /// <param name = "tagsParameter">The tags that must be added to the GameObject</param> public static void AddTags(this GameObject value, params Tags[] tagsParameter) { Debug.Assert(value != null && tagsParameter != null); MultiTags CurrentGameComponent = value.AddOnlyOneComponent <MultiTags>(); foreach (Tags tag in tagsParameter) { if (CurrentGameComponent.tags.BinarySearch(tag) < 0) { CurrentGameComponent.tags.Add(tag); } } CurrentGameComponent.tags.Sort(); }
/// <summary> /// Remove these tags in the specific GameObject /// </summary> /// <param name = "value">The specific gameobject</param> /// <param name = "tagsParameter">The tags that must be removed to the GameObject</param> public static void RemoveTags(this GameObject value, params Tags[] tagsParameter) { Debug.Assert(value != null && tagsParameter != null); MultiTags CurrentGameComponent = value.GetComponent <MultiTags>(); if (CurrentGameComponent == null || tagsParameter.Length == 0) { return; } foreach (Tags tag in tagsParameter) { CurrentGameComponent.tags.Remove(tag); } CurrentGameComponent.tags.Sort(); }