Created
March 29, 2014 02:10
-
-
Save kimsama/9847077 to your computer and use it in GitHub Desktop.
extending method to already exist class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class TransformHelper | |
| { | |
| public static Transform GetChild(this Transform self, string name) | |
| { | |
| Transform t = null; | |
| if(name != "") | |
| t = self.Find(name); | |
| if(t == null) | |
| t = self; | |
| return t; | |
| } | |
| public static Transform FindChildByName(this Transform self, string childname) | |
| { | |
| Transform found = null; | |
| if (self.name == childname) | |
| return self.transform; | |
| foreach (Transform child in self) | |
| { | |
| found = child.FindChildByName(childname); | |
| if (found) | |
| { | |
| return found; | |
| } | |
| } | |
| return null; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment