天天看點

編輯器拓展 => 自定義快捷鍵

控制所選層級面闆物體的激活狀态

public class GameObjectControl
{
    //控制目前選擇對象的顯示 alt + f
    [MenuItem("Toolkit/GameObject/Active GameObject  &f")]
    public static void ActiveGameObject()
    {
        GameObject[] objs = Selection.gameObjects;
        if (objs.Length == 0) return;
        bool isActive = !objs[0].activeSelf;
        for (int i = 0; i < objs.Length; i++)
        {
            objs[i].SetActive(isActive);
        }
    }
}