Unity 3D扩展类
什么事Unity 3D扩展类
在不修改这个类的情况下,给类添加新的方法
public static class UIExtension {
public static FindButton(this Transform root, string name) {
Transform[] transforms = root.GetComponentInChildren<Transform>(true);
foreach (var item in transforms)
{
if (item.name == name) {
return item.GetComponent<Button>();
}
}
Debug.LogWarning("not find button:" + name);
return null;
}
}