【Unity3D编辑器扩展】Unity Editor自定义快捷键

推荐阅读

一、前言

在使用Unity中可能需要使用快捷键执行一些操作,或者修改Unity自带的快捷键,接下来就看一下,如何设置自定义快捷键吧

效果:
在这里插入图片描述

二、快捷键大全

快捷键指令
%CTRL
#Shift
&Alt
LEFT/RIGHT/UP/DOWN箭头上下左右
F1-F12键盘快捷键F1-F12
HOME/END/PGUP/PDDN对应键盘的Home/End/PageUp/PageDown

三、实例

代码:

using UnityEditor;
using UnityEngine;

public class CustomKeys : Editor
{
    [MenuItem("Custom快捷键/F1按键 _F1")]
    static void EditorCustorkKeys1()
    {
        Debug.Log("F1点击执行的指令");
    }
}

这个就是自定义了一个F1的快捷键指令

using UnityEditor;
using UnityEngine;

public class CustomKeys : Editor
{
    [MenuItem("Custom快捷键/Ctrl+Q %Q")]
    static void EditorCustorkKeys2()
    {
        Debug.Log("Ctrl+Q点击执行的指令");
    }
}

组合快捷键Ctrl+Q

using UnityEditor;
using UnityEngine;

public class CustomKeys : Editor
{
    [MenuItem("Custom快捷键/Ctrl+Shift+Q %#Q")]
    static void EditorCustorkKeys3()
    {
        Debug.Log("Ctrl+Shift+Q点击执行的指令");
    }
}

组合快捷键Ctrl+Shift+Q

[MenuItem(“Custom快捷键/Ctrl+Shift+Q %#Q”)]

Custom快捷键: 自定义,随便写
Ctrl+Shift+Q: 自定义,随便写
%#Q: 快捷键设置,Ctrl=% Shift=# Q=Q。。前面记得加空格.

四、功能实例

暂停编辑器:
EditorApplication.isPaused = !EditorApplication.isPaused;

播放:
EditorApplication.isPlaying = true;

单步执行:
EditorApplication.Step();

打开场景,并运行
EditorSceneManager.OpenScene(“Assets/Scenes/LandInit.unity”);
EditorApplication.isPlaying = true;

好的,下课

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

恬静的小魔龙

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值