Example #1
0
        /// <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);
        }
Example #2
0
        /// <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));
        }
Example #3
0
        /// <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();
        }
Example #4
0
        /// <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();
        }