/** * Find */ public static IEnumerable <GameObject> FindGameObjectsWithMultiTag(string tag) { if (tag == SPConstants.TAG_MULTITAG) { foreach (var go in GameObject.FindGameObjectsWithTag(SPConstants.TAG_MULTITAG)) { yield return(go); } } else { foreach (var go in GameObject.FindGameObjectsWithTag(tag)) { yield return(go); } //MultiTag comp; //foreach (var go in GameObject.FindGameObjectsWithTag(SPConstants.TAG_MULTITAG)) //{ // if (go.GetComponent<MultiTag>(out comp)) // { // if (comp.ContainsTag(tag)) yield return go; // } //} foreach (var c in MultiTag.FindAll(tag)) { yield return(c.gameObject); } } }
/** * Find */ public static GameObject[] FindGameObjectsWithMultiTag(string tag) { if (tag == SPConstants.TAG_MULTITAG) { return(GameObject.FindGameObjectsWithTag(SPConstants.TAG_MULTITAG)); } else { using (var tmp = TempList <GameObject> .GetList()) { foreach (var go in GameObject.FindGameObjectsWithTag(tag)) { tmp.Add(go); } MultiTag.FindAll(tag, tmp); return(tmp.ToArray()); } } }
public static int FindGameObjectsWithMultiTag(string tag, ICollection <UnityEngine.GameObject> coll) { if (coll == null) { throw new System.ArgumentNullException("coll"); } int cnt = coll.Count; if (tag == SPConstants.TAG_MULTITAG) { coll.AddRange(GameObject.FindGameObjectsWithTag(SPConstants.TAG_MULTITAG)); } else { foreach (var go in GameObject.FindGameObjectsWithTag(tag)) { coll.Add(go); } MultiTag.FindAll(tag, coll); } return(coll.Count - cnt); }
public static void FindGameObjectsWithMultiTag(string tag, ICollection <UnityEngine.GameObject> coll) { if (coll == null) { throw new System.ArgumentNullException("coll"); } if (tag == SPConstants.TAG_MULTITAG) { coll.AddRange(GameObject.FindGameObjectsWithTag(SPConstants.TAG_MULTITAG)); } else { foreach (var go in GameObject.FindGameObjectsWithTag(tag)) { coll.Add(go); } foreach (var c in MultiTag.FindAll(tag)) { coll.Add(c.gameObject); } } }