参考链接:
Unity官方论坛
Unity官方手册
[MenuItem("Tools/GetSelectPaths")]
public static void Execute()
{
string[] strs = Selection.assetGUIDs;
var curPath = System.IO.Directory.GetCurrentDirectory();
foreach (var item in strs)
{
string path = AssetDatabase.GUIDToAssetPath(item);
Debug.Log(curPath+"/"+path);
}
}
[MenuItem("Example/Toggle Active of Selected %i")]
static void DoToggle()
{
Object[] activeGOs = Selection.GetFiltered(
typeof(GameObject),
SelectionMode.Editable | SelectionMode.TopLevel);
foreach (GameObject obj in activeGOs)
{
obj.SetActive(!obj.activeSelf);
}
}