15
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Unityでショートカットキーの自作

Posted at

Editor拡張でショートカットキーを自作してみます。

using UnityEditor;
using UnityEngine;

public class Test : Editor
{
    // % が Windowsで Ctrlキー, Macで Cmdキー
    [MenuItem("Shortcut/Ctrl+i or Cmd+i %i")]
    static public void CtrlOrCmdPlusKey()
    {
        // Windowsの場合は Ctrlキー + iキー
        // Macの場合は Commandキー + iキー
        Debug.Log("CtrlOrCmdPlusKey");
    }

    // # が Shiftキー
    [MenuItem("Shortcut/Shift+k #k")]
    static public void ShiftPlusKey()
    {
        // Shiftキー + kキー
        Debug.Log("ShiftPlusKey");
    }

    // & が Altキー
    [MenuItem("Shortcut/Alt+d &d")]
    static public void AltPlusKey()
    {
        // Altキー + dキー
        Debug.Log("AltPlusKey");
    }

    // _ が キーの修飾子なしの意味
    [MenuItem("Shortcut/N _n")]
    static public void OnlyKey()
    {
        // nキーのみ
        Debug.Log("OnlyKey");
    }

    // このように組み合わせもできる
    [MenuItem("Shortcut/Cmd+Shift+j #%j")]
    static public void CombinationKey()
    {
        Debug.Log("CombinationKey");
    }
}

既存のUnityキーとかぶらないように注意して作成することとします。

15
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?