Selection.activeObject:可以获取选中的节点
using UnityEngine;
using System.Collections;
using UnityEditor;
public class MyEditorClearLabel
{
//批量清除UILabel的内容
[MenuItem ("ToolClear/ClearUILabel")]
static void ClearUILabel ()
{
if(Selection.activeObject != null)
{
UILabel[] trans = ((GameObject)Selection.activeObject).GetComponentsInChildren<UILabel>(true);
for(int i = 0; i < trans.Length; ++i)
{
trans[i].text = "";
}
}
}
}using