[MenuItem("Tools/add all buttonScale")]
public static void AddScale()
{
var allAssets = AssetDatabase.GetAllAssetPath();
Object obj;
GameObject go;
foreach(var assetPath in allAssets)
{
if (assetPath.LastIndexOf(".prefab")<0) continue;
obj = AssetDatabase.LoadMainAssetAtPath(assetPath);
go = obj as GameObject;
if (go != null)
{
CheckOneGo(go);
}
}
}
[MenuItem("Tools/add selection buttonScale")]
public static void AddOneScale()
{
var selecteds = Selection.GetFiltered(typeof(Object), SelectionMode.Unfiltered);
GameObject go;
foreach(var selectAsset in selecteds)
{
go = selectAsset as GameObject;
if (go != null)
{
CheckOneGo(go);
}
}
}
private static void CheckOneGo(GameObject go)
{
Button btn;
buttonScale scale;
btn = go.GetComponent<Button>();
if (btn != null)
{
scale = go.GetComponent<buttonScale>();
if (scale == null)
{
go.AddComponent<ButtonScale>();
EditorUtility.SetDirty(go);
}
}
int childCount = go.transform.childCount;
for(int i=0; i < childCount; i++)
{
CheckOneGo(go.transform.GetChild(i).gameObject);
}
}