public List <GameObject> GetObjectsOfType(Type type) { List <GameObject> ret = new List <GameObject>(); int count = ObjectsDictionary.Count; GameObject temp; Stack <GameObject> objStack = new Stack <GameObject>(); for (int i = 0; i < count; ++i) { objStack.Push(ObjectsDictionary.ElementAt(i).Value); while (objStack.Count > 0) { temp = objStack.Pop(); if (temp.GetType() == type) { ret.Add(temp); } List <GameObject> children = temp.GetChildren(); int cCount = children.Count; for (int j = 0; j < cCount; ++j) { objStack.Push(children[j]); } } } return(ret); }
public List <ObjectComponent> GetComponentsOfType(Type type) { List <ObjectComponent> ret = new List <ObjectComponent>(); int count = ObjectsDictionary.Count; GameObject temp; ObjectComponent tempC; Stack <GameObject> objStack = new Stack <GameObject>(); for (int i = 0; i < count; ++i) { objStack.Push(ObjectsDictionary.ElementAt(i).Value); while (objStack.Count > 0) { temp = objStack.Pop(); if (temp.MyAnimator != null && temp.MyAnimator.GetType() == type) { ret.Add(temp.MyAnimator); } if (temp.MyCarrierSocket != null && temp.MyCarrierSocket.GetType() == type) { ret.Add(temp.MyCarrierSocket); } if (temp.MyCollider != null && temp.MyCollider.GetType() == type) { ret.Add(temp.MyCollider); } if (temp.MyPhysicalObject != null && temp.MyPhysicalObject.GetType() == type) { ret.Add(temp.MyPhysicalObject); } if (temp.MyTransform != null && temp.MyTransform.GetType() == type) { ret.Add(temp.MyTransform); } int countC = temp.Components.Count; for (int j = 0; j < countC; ++j) { tempC = temp.Components[j]; if (tempC.GetType() == type) { ret.Add(tempC); } } List <GameObject> children = temp.GetChildren(); int cCount = children.Count; for (int j = 0; j < cCount; ++j) { objStack.Push(children[j]); } } } return(ret); }