UnityEngine.GameObject.CompareTag C# (CSharp) Method

CompareTag() public method

public CompareTag ( string tag ) : bool
tag string
return bool
		public bool CompareTag(string tag){}
		public static GameObject FindGameObjectWithTag(string tag){}

Usage Example

Example #1
0
 public static List <UnityEngine.GameObject> FindChildWithTag(UnityEngine.GameObject Parent, string tag)
 {
     if (Parent.transform.childCount == 0)
     {
         if (!Parent.CompareTag(tag))
         {
             return(new List <UnityEngine.GameObject>());
         }
         else
         {
             return new List <UnityEngine.GameObject>()
                    {
                        Parent
                    }
         };
     }
     else
     {
         List <UnityEngine.GameObject> res = new List <UnityEngine.GameObject>();
         for (int i = 0; i < Parent.transform.childCount; i++)
         {
             res.AddRange(FindChildWithTag(Parent.transform.GetChild(i).gameObject, tag));
         }
         if (Parent.CompareTag(tag))
         {
             res.Add(Parent);
         }
         return(res);
     }
 }
All Usage Examples Of UnityEngine.GameObject::CompareTag