首页 > 技术文章 > unity-编辑器快捷按键

Jaysonhome 2020-07-12 13:44 原文

  • 效果图

  • 代码

    [MenuItem("Custom/Run _F1")]
    static void PlayToggle()
    {
        EditorApplication.isPlaying = !EditorApplication.isPlaying;
    } 

    static MethodInfo clearMethod = null;
    [MenuItem("Custom/Clear Console %#z")]
    private static void ClearConsole()
    {
        if (clearMethod == null)
        {
            Type log = typeof(EditorWindow).Assembly.GetType("UnityEditor.LogEntries");
            clearMethod = log.GetMethod("Clear");
        }
        clearMethod.Invoke(null, null);
    }

推荐阅读