“想玩点花式?” 试试快捷键操作编辑器吧(Unity3D)

1,015 阅读1分钟

推荐阅读

一、前言

在使用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;