Last active
August 29, 2015 14:15
-
-
Save enpel/26baa531ea74ecad7425 to your computer and use it in GitHub Desktop.
GameObjectの拡張どっこいしょ
This file contains 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
using UnityEngine; | |
using System.Collections; | |
public static class GameObjectExtensions | |
{ | |
// GameObjectの子にいるGameObjectを名前で取得する | |
public static GameObject FindChild (this GameObject parent, string name) | |
{ | |
Transform child =parent.transform.Find(name); | |
return child == null ? null : child.gameObject; | |
} | |
// 子供を全員Destroy!KillThemALL!!!(DestroyAllChildrenとかの方がわかりやすいと思います | |
public static void KillChildrenAll(this GameObject current) | |
{ | |
foreach ( Transform n in current.transform ) | |
{ | |
GameObject.Destroy(n.gameObject); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment