国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

【Unity3D編輯器開(kāi)發(fā)】Unity3D中實(shí)現(xiàn)查看鍵盤(pán)對(duì)應(yīng)KeyCode值面板【方便開(kāi)發(fā)】

這篇具有很好參考價(jià)值的文章主要介紹了【Unity3D編輯器開(kāi)發(fā)】Unity3D中實(shí)現(xiàn)查看鍵盤(pán)對(duì)應(yīng)KeyCode值面板【方便開(kāi)發(fā)】。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

推薦閱讀

  • CSDN主頁(yè)
  • GitHub開(kāi)源地址
  • Unity3D插件分享
  • 簡(jiǎn)書(shū)地址
  • 我的個(gè)人博客

大家好,我是佛系工程師☆恬靜的小魔龍☆,不定時(shí)更新Unity開(kāi)發(fā)技巧,覺(jué)得有用記得一鍵三連哦。

一、前言

在開(kāi)發(fā)中,會(huì)遇到要使用監(jiān)控鍵盤(pán)輸入的KeyCode值來(lái)執(zhí)行代碼的情況。

比如說(shuō):

using System;
using UnityEditor;
using UnityEngine;

public class Test01 : MonoBehaviour
{
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.W))
        {
			 Debug.Log("點(diǎn)擊了鍵盤(pán)W");
        }
    }
}

但是,如果是一些不常用的鍵位,比如說(shuō){}[],這些KeyCode值就比較難查看了,因?yàn)锳PI是這樣的:
【Unity3D編輯器開(kāi)發(fā)】Unity3D中實(shí)現(xiàn)查看鍵盤(pán)對(duì)應(yīng)KeyCode值面板【方便開(kāi)發(fā)】,# Unity3D之編輯器擴(kuò)展,編輯器,計(jì)算機(jī)外設(shè),c#,unity
根本不知道這英文還是數(shù)字代表了啥,于是就誕生了,在Unity做一個(gè)鍵盤(pán),然后在鍵盤(pán)的鍵位下標(biāo)注每個(gè)鍵位的KeyCode值,方便開(kāi)發(fā)。

先看下效果圖:
【Unity3D編輯器開(kāi)發(fā)】Unity3D中實(shí)現(xiàn)查看鍵盤(pán)對(duì)應(yīng)KeyCode值面板【方便開(kāi)發(fā)】,# Unity3D之編輯器擴(kuò)展,編輯器,計(jì)算機(jī)外設(shè),c#,unity

小明:鍵位沒(méi)有對(duì)齊,逼死強(qiáng)迫癥啊喂!
張三:不重要!不重要!

二、正文

2-1、構(gòu)建鍵盤(pán)鍵值表

讓我們新建一個(gè)腳本,命名為VirtualKeyboardEditor.cs名字無(wú)所謂,主要是要繼承與EditorWindow類,并且把腳本放到Editor文件夾內(nèi)。

編輯代碼:

using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class VirtualKeyboardEditor : EditorWindow
{
    [MenuItem("工具/鍵盤(pán)映射值")]
    static void OpenWindow()
    {
        GetWindow<VirtualKeyboardEditor>().Show();
    }
    //用于繪制窗口內(nèi)容
    private void OnGUI()
    {
    }
}

然后,我們需要寫(xiě)一個(gè)自定義類,用來(lái)保存鍵盤(pán)值名和KeyCode值,以及長(zhǎng)寬。

// 鍵盤(pán)映射value值
public class VirKeyValue
{
    public float height;
    public float width;
    public string name;
    public string key;
    public VirKeyValue(string name, string key, float width, float height)
    {
        this.name = name;
        this.width = width;
        this.height = height;
        this.key = key;
    }
}

接著構(gòu)建鍵值庫(kù):

static Dictionary<int, List<VirKeyValue>> dicVirKeys;
    const int width1 = 50;
    const int width2 = 80;
    const int width100 = 100;
    const int width120 = 120;
    const int width140 = 138;
    const int width3 = 300;
    const int height1 = 30;

    private void DataInit()
    {
        if (dicVirKeys == null)
        {
            dicVirKeys = new Dictionary<int, List<VirKeyValue>>();
            List<VirKeyValue> tempVirKeys = new List<VirKeyValue>
            {
                new VirKeyValue("Esc","Esc", width1, height1),
                new VirKeyValue("F1","F1", width1, height1),
                new VirKeyValue("F2","F2", width1, height1),
                new VirKeyValue("F3","F3", width1, height1),
                new VirKeyValue("F4","F4", width1, height1),
                new VirKeyValue("F5","F5", width1, height1),
                new VirKeyValue("F6","F6", width1, height1),
                new VirKeyValue("F7","F7", width1, height1),
                new VirKeyValue("F8","F8", width1, height1),
                new VirKeyValue("F9","F9", width1, height1),
                new VirKeyValue("F10","F10", width1, height1),
                new VirKeyValue("F11","F11", width1, height1),
                new VirKeyValue("F12","F12", width1, height1),
                new VirKeyValue("Print\nScreen","Print", width1, height1),
                new VirKeyValue("Scroll\nLock", "ScrollLockScroll",width1, height1),
                new VirKeyValue("Pause","Pause", width1, height1)
            };
            dicVirKeys.Add(0, tempVirKeys);

            tempVirKeys = new List<VirKeyValue>
            {
                new VirKeyValue("~\n`","BackQuote", width1, height1),
                new VirKeyValue("!\n1","Alpha1", width1, height1),
                new VirKeyValue("@\n2","Alpha2", width1, height1),
                new VirKeyValue("#\n3","Alpha3", width1, height1),
                new VirKeyValue("$\n4","Alpha4", width1, height1),
                new VirKeyValue("%\n5","Alpha5", width1, height1),
                new VirKeyValue("^\n6","Alpha6", width1, height1),
                new VirKeyValue("&\n7","Alpha7", width1, height1),
                new VirKeyValue("*\n8","Alpha8", width1, height1),
                new VirKeyValue("(\n9","Alpha9", width1, height1),
                new VirKeyValue(")\n0","Alpha0", width1, height1),
                new VirKeyValue("_\n-","Minus", width1, height1),
                new VirKeyValue("+\n=","Equals", width1, height1),
                new VirKeyValue("←Backspace","Backspace", width120, height1),
                new VirKeyValue("Insert","Insert", width1, height1),
                new VirKeyValue("Home", "Home",width1, height1),
                new VirKeyValue("Page\nUp", "PageUp",width1, height1),
                new VirKeyValue("NumLk","Numlock", width1, height1),
                new VirKeyValue("/","KeypadDivide", width1, height1),
                new VirKeyValue("*","KeypadMultiply", width1, height1),
                new VirKeyValue("-","KeypadMinus", width1, height1),
            };
            dicVirKeys.Add(1, tempVirKeys);

            tempVirKeys = new List<VirKeyValue>
            {
                new VirKeyValue("Tab","Tab", width100, height1),
                new VirKeyValue("Q","Q",width1, height1),
                new VirKeyValue("W","W",width1, height1),
                new VirKeyValue("E","E",width1, height1),
                new VirKeyValue("R","R",width1, height1),
                new VirKeyValue("T","T",width1, height1),
                new VirKeyValue("Y","Y",width1, height1),
                new VirKeyValue("U","U",width1, height1),
                new VirKeyValue("I","I",width1, height1),
                new VirKeyValue("O","O",width1, height1),
                new VirKeyValue("P","P",width1, height1),
                new VirKeyValue("{\n[","LeftBracket", width1, height1),
                new VirKeyValue("}\n]","RightBracket", width1, height1),
                new VirKeyValue("|\n\\", "Backslash",70, height1),
                new VirKeyValue("Delete", "Delete",width1, height1),
                new VirKeyValue("End", "End",width1, height1),
                new VirKeyValue("Page\nDown","PageDown", width1, height1),
                new VirKeyValue("7","Keypad7",width1, height1),
                new VirKeyValue("8","Keypad8",width1, height1),
                new VirKeyValue("9","Keypad9",width1, height1),
                new VirKeyValue("+","KeypadPlus",width1, height1),
            };
            dicVirKeys.Add(2, tempVirKeys);

            tempVirKeys = new List<VirKeyValue>
            {
                new VirKeyValue("Caps\nLock","Backspace", width120, height1),
                new VirKeyValue("A","A", width1, height1),
                new VirKeyValue("S","S", width1, height1),
                new VirKeyValue("D","D", width1, height1),
                new VirKeyValue("F","F", width1, height1),
                new VirKeyValue("G","G", width1, height1),
                new VirKeyValue("H","H", width1, height1),
                new VirKeyValue("J","J", width1, height1),
                new VirKeyValue("K","K", width1, height1),
                new VirKeyValue("L","L", width1, height1),
                new VirKeyValue(":\n;","Semicolon", width1, height1),
                new VirKeyValue("\"\n'","Quote", width1, height1),
                new VirKeyValue("Enter","Enter", 104, height1),
                new VirKeyValue("4","Keypad4",width1, height1),
                new VirKeyValue("5","Keypad5",width1, height1),
                new VirKeyValue("6","Keypad6",width1, height1),
                new VirKeyValue("Enter","KeypadEnter", width1, height1),
            };
            dicVirKeys.Add(3, tempVirKeys);

            tempVirKeys = new List<VirKeyValue>
            {
                new VirKeyValue("Shift","LeftShift", width140, height1),
                new VirKeyValue("Z","Z",width1, height1),
                new VirKeyValue("X","X",width1, height1),
                new VirKeyValue("C","C",width1, height1),
                new VirKeyValue("V","V",width1, height1),
                new VirKeyValue("B","B",width1, height1),
                new VirKeyValue("N","N",width1, height1),
                new VirKeyValue("M","M",width1, height1),
                new VirKeyValue("<\n,","Comma", width1, height1),
                new VirKeyValue(">\n.","Period", width1, height1),
                new VirKeyValue("?\n/","Slash", width1, height1),
                new VirKeyValue("Shift","RightControl", width140, height1),
                new VirKeyValue("↑","UpArrow", width1, height1),
                new VirKeyValue("1","Keypad1", width1, height1),
                new VirKeyValue("2","Keypad2", width1, height1),
                new VirKeyValue("3","Keypad3", width1, height1),
            };
            dicVirKeys.Add(4, tempVirKeys);

            tempVirKeys = new List<VirKeyValue>
            {
                new VirKeyValue("Ctrl","LeftControl", width2, height1),
                new VirKeyValue("Win", "LeftWindows",width1, height1),
                new VirKeyValue("Alt", "LeftAlt",width1, height1),
                new VirKeyValue("—————Space———","Space", width3, height1),
                new VirKeyValue("Alt", "RightAlt",width1, height1),
                new VirKeyValue("Ctrl", "RightControl",width2, height1),
                new VirKeyValue("←","LeftArrow",width1, height1),
                new VirKeyValue("↓","DownArrow",width1, height1),
                new VirKeyValue("→","RightArrow",width1, height1),
                new VirKeyValue("0","Keypad0",width100, height1),
                new VirKeyValue(".","KeypadPeriod",width1, height1),
            };
            dicVirKeys.Add(5, tempVirKeys);
        }
    }

整體代碼如下:

using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

// 鍵盤(pán)映射value值
public class VirKeyValue
{
    public float height;
    public float width;
    public string name;
    public string key;
    public VirKeyValue(string name, string key, float width, float height)
    {
        this.name = name;
        this.width = width;
        this.height = height;
        this.key = key;
    }
}
public class VirtualKeyboardEditor : EditorWindow
{
    [MenuItem("工具/鍵盤(pán)映射值")]
    static void OpenWindow()
    {
        GetWindow<VirtualKeyboardEditor>().Show();
    }

    static Dictionary<int, List<VirKeyValue>> dicVirKeys;
    const int width1 = 50;
    const int width2 = 80;
    const int width100 = 100;
    const int width120 = 120;
    const int width140 = 138;
    const int width3 = 300;
    const int height1 = 30;

    private void DataInit()
    {
        if (dicVirKeys == null)
        {
            dicVirKeys = new Dictionary<int, List<VirKeyValue>>();
            List<VirKeyValue> tempVirKeys = new List<VirKeyValue>
            {
                new VirKeyValue("Esc","Esc", width1, height1),
                new VirKeyValue("F1","F1", width1, height1),
                new VirKeyValue("F2","F2", width1, height1),
                new VirKeyValue("F3","F3", width1, height1),
                new VirKeyValue("F4","F4", width1, height1),
                new VirKeyValue("F5","F5", width1, height1),
                new VirKeyValue("F6","F6", width1, height1),
                new VirKeyValue("F7","F7", width1, height1),
                new VirKeyValue("F8","F8", width1, height1),
                new VirKeyValue("F9","F9", width1, height1),
                new VirKeyValue("F10","F10", width1, height1),
                new VirKeyValue("F11","F11", width1, height1),
                new VirKeyValue("F12","F12", width1, height1),
                new VirKeyValue("Print\nScreen","Print", width1, height1),
                new VirKeyValue("Scroll\nLock", "ScrollLockScroll",width1, height1),
                new VirKeyValue("Pause","Pause", width1, height1)
            };
            dicVirKeys.Add(0, tempVirKeys);

            tempVirKeys = new List<VirKeyValue>
            {
                new VirKeyValue("~\n`","BackQuote", width1, height1),
                new VirKeyValue("!\n1","Alpha1", width1, height1),
                new VirKeyValue("@\n2","Alpha2", width1, height1),
                new VirKeyValue("#\n3","Alpha3", width1, height1),
                new VirKeyValue("$\n4","Alpha4", width1, height1),
                new VirKeyValue("%\n5","Alpha5", width1, height1),
                new VirKeyValue("^\n6","Alpha6", width1, height1),
                new VirKeyValue("&\n7","Alpha7", width1, height1),
                new VirKeyValue("*\n8","Alpha8", width1, height1),
                new VirKeyValue("(\n9","Alpha9", width1, height1),
                new VirKeyValue(")\n0","Alpha0", width1, height1),
                new VirKeyValue("_\n-","Minus", width1, height1),
                new VirKeyValue("+\n=","Equals", width1, height1),
                new VirKeyValue("←Backspace","Backspace", width120, height1),
                new VirKeyValue("Insert","Insert", width1, height1),
                new VirKeyValue("Home", "Home",width1, height1),
                new VirKeyValue("Page\nUp", "PageUp",width1, height1),
                new VirKeyValue("NumLk","Numlock", width1, height1),
                new VirKeyValue("/","KeypadDivide", width1, height1),
                new VirKeyValue("*","KeypadMultiply", width1, height1),
                new VirKeyValue("-","KeypadMinus", width1, height1),
            };
            dicVirKeys.Add(1, tempVirKeys);

            tempVirKeys = new List<VirKeyValue>
            {
                new VirKeyValue("Tab","Tab", width100, height1),
                new VirKeyValue("Q","Q",width1, height1),
                new VirKeyValue("W","W",width1, height1),
                new VirKeyValue("E","E",width1, height1),
                new VirKeyValue("R","R",width1, height1),
                new VirKeyValue("T","T",width1, height1),
                new VirKeyValue("Y","Y",width1, height1),
                new VirKeyValue("U","U",width1, height1),
                new VirKeyValue("I","I",width1, height1),
                new VirKeyValue("O","O",width1, height1),
                new VirKeyValue("P","P",width1, height1),
                new VirKeyValue("{\n[","LeftBracket", width1, height1),
                new VirKeyValue("}\n]","RightBracket", width1, height1),
                new VirKeyValue("|\n\\", "Backslash",70, height1),
                new VirKeyValue("Delete", "Delete",width1, height1),
                new VirKeyValue("End", "End",width1, height1),
                new VirKeyValue("Page\nDown","PageDown", width1, height1),
                new VirKeyValue("7","Keypad7",width1, height1),
                new VirKeyValue("8","Keypad8",width1, height1),
                new VirKeyValue("9","Keypad9",width1, height1),
                new VirKeyValue("+","KeypadPlus",width1, height1),
            };
            dicVirKeys.Add(2, tempVirKeys);

            tempVirKeys = new List<VirKeyValue>
            {
                new VirKeyValue("Caps\nLock","Backspace", width120, height1),
                new VirKeyValue("A","A", width1, height1),
                new VirKeyValue("S","S", width1, height1),
                new VirKeyValue("D","D", width1, height1),
                new VirKeyValue("F","F", width1, height1),
                new VirKeyValue("G","G", width1, height1),
                new VirKeyValue("H","H", width1, height1),
                new VirKeyValue("J","J", width1, height1),
                new VirKeyValue("K","K", width1, height1),
                new VirKeyValue("L","L", width1, height1),
                new VirKeyValue(":\n;","Semicolon", width1, height1),
                new VirKeyValue("\"\n'","Quote", width1, height1),
                new VirKeyValue("Enter","Enter", 104, height1),
                new VirKeyValue("4","Keypad4",width1, height1),
                new VirKeyValue("5","Keypad5",width1, height1),
                new VirKeyValue("6","Keypad6",width1, height1),
                new VirKeyValue("Enter","KeypadEnter", width1, height1),
            };
            dicVirKeys.Add(3, tempVirKeys);

            tempVirKeys = new List<VirKeyValue>
            {
                new VirKeyValue("Shift","LeftShift", width140, height1),
                new VirKeyValue("Z","Z",width1, height1),
                new VirKeyValue("X","X",width1, height1),
                new VirKeyValue("C","C",width1, height1),
                new VirKeyValue("V","V",width1, height1),
                new VirKeyValue("B","B",width1, height1),
                new VirKeyValue("N","N",width1, height1),
                new VirKeyValue("M","M",width1, height1),
                new VirKeyValue("<\n,","Comma", width1, height1),
                new VirKeyValue(">\n.","Period", width1, height1),
                new VirKeyValue("?\n/","Slash", width1, height1),
                new VirKeyValue("Shift","RightControl", width140, height1),
                new VirKeyValue("↑","UpArrow", width1, height1),
                new VirKeyValue("1","Keypad1", width1, height1),
                new VirKeyValue("2","Keypad2", width1, height1),
                new VirKeyValue("3","Keypad3", width1, height1),
            };
            dicVirKeys.Add(4, tempVirKeys);

            tempVirKeys = new List<VirKeyValue>
            {
                new VirKeyValue("Ctrl","LeftControl", width2, height1),
                new VirKeyValue("Win", "LeftWindows",width1, height1),
                new VirKeyValue("Alt", "LeftAlt",width1, height1),
                new VirKeyValue("—————Space———","Space", width3, height1),
                new VirKeyValue("Alt", "RightAlt",width1, height1),
                new VirKeyValue("Ctrl", "RightControl",width2, height1),
                new VirKeyValue("←","LeftArrow",width1, height1),
                new VirKeyValue("↓","DownArrow",width1, height1),
                new VirKeyValue("→","RightArrow",width1, height1),
                new VirKeyValue("0","Keypad0",width100, height1),
                new VirKeyValue(".","KeypadPeriod",width1, height1),
            };
            dicVirKeys.Add(5, tempVirKeys);
        }
    }
    //用于繪制窗口內(nèi)容
    private void OnGUI()
    {
    }
}

2-2、界面繪制

using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

// 鍵盤(pán)映射value值
public class VirKeyValue
{
    public float height;
    public float width;
    public string name;
    public string key;
    public VirKeyValue(string name, string key, float width, float height)
    {
        this.name = name;
        this.width = width;
        this.height = height;
        this.key = key;
    }
}
public class VirtualKeyboardEditor : EditorWindow
{
    [MenuItem("工具/鍵盤(pán)映射值")]
    static void OpenWindow()
    {
        GetWindow<VirtualKeyboardEditor>().Show();
    }

    static Dictionary<int, List<VirKeyValue>> dicVirKeys;
    const int width1 = 50;
    const int width2 = 80;
    const int width100 = 100;
    const int width120 = 120;
    const int width140 = 138;
    const int width3 = 300;
    const int height1 = 30;

    private void DataInit()
    {
        if (dicVirKeys == null)
        {
            dicVirKeys = new Dictionary<int, List<VirKeyValue>>();
            List<VirKeyValue> tempVirKeys = new List<VirKeyValue>
            {
                new VirKeyValue("Esc","Esc", width1, height1),
                new VirKeyValue("F1","F1", width1, height1),
                new VirKeyValue("F2","F2", width1, height1),
                new VirKeyValue("F3","F3", width1, height1),
                new VirKeyValue("F4","F4", width1, height1),
                new VirKeyValue("F5","F5", width1, height1),
                new VirKeyValue("F6","F6", width1, height1),
                new VirKeyValue("F7","F7", width1, height1),
                new VirKeyValue("F8","F8", width1, height1),
                new VirKeyValue("F9","F9", width1, height1),
                new VirKeyValue("F10","F10", width1, height1),
                new VirKeyValue("F11","F11", width1, height1),
                new VirKeyValue("F12","F12", width1, height1),
                new VirKeyValue("Print\nScreen","Print", width1, height1),
                new VirKeyValue("Scroll\nLock", "ScrollLockScroll",width1, height1),
                new VirKeyValue("Pause","Pause", width1, height1)
            };
            dicVirKeys.Add(0, tempVirKeys);

            tempVirKeys = new List<VirKeyValue>
            {
                new VirKeyValue("~\n`","BackQuote", width1, height1),
                new VirKeyValue("!\n1","Alpha1", width1, height1),
                new VirKeyValue("@\n2","Alpha2", width1, height1),
                new VirKeyValue("#\n3","Alpha3", width1, height1),
                new VirKeyValue("$\n4","Alpha4", width1, height1),
                new VirKeyValue("%\n5","Alpha5", width1, height1),
                new VirKeyValue("^\n6","Alpha6", width1, height1),
                new VirKeyValue("&\n7","Alpha7", width1, height1),
                new VirKeyValue("*\n8","Alpha8", width1, height1),
                new VirKeyValue("(\n9","Alpha9", width1, height1),
                new VirKeyValue(")\n0","Alpha0", width1, height1),
                new VirKeyValue("_\n-","Minus", width1, height1),
                new VirKeyValue("+\n=","Equals", width1, height1),
                new VirKeyValue("←Backspace","Backspace", width120, height1),
                new VirKeyValue("Insert","Insert", width1, height1),
                new VirKeyValue("Home", "Home",width1, height1),
                new VirKeyValue("Page\nUp", "PageUp",width1, height1),
                new VirKeyValue("NumLk","Numlock", width1, height1),
                new VirKeyValue("/","KeypadDivide", width1, height1),
                new VirKeyValue("*","KeypadMultiply", width1, height1),
                new VirKeyValue("-","KeypadMinus", width1, height1),
            };
            dicVirKeys.Add(1, tempVirKeys);

            tempVirKeys = new List<VirKeyValue>
            {
                new VirKeyValue("Tab","Tab", width100, height1),
                new VirKeyValue("Q","Q",width1, height1),
                new VirKeyValue("W","W",width1, height1),
                new VirKeyValue("E","E",width1, height1),
                new VirKeyValue("R","R",width1, height1),
                new VirKeyValue("T","T",width1, height1),
                new VirKeyValue("Y","Y",width1, height1),
                new VirKeyValue("U","U",width1, height1),
                new VirKeyValue("I","I",width1, height1),
                new VirKeyValue("O","O",width1, height1),
                new VirKeyValue("P","P",width1, height1),
                new VirKeyValue("{\n[","LeftBracket", width1, height1),
                new VirKeyValue("}\n]","RightBracket", width1, height1),
                new VirKeyValue("|\n\\", "Backslash",70, height1),
                new VirKeyValue("Delete", "Delete",width1, height1),
                new VirKeyValue("End", "End",width1, height1),
                new VirKeyValue("Page\nDown","PageDown", width1, height1),
                new VirKeyValue("7","Keypad7",width1, height1),
                new VirKeyValue("8","Keypad8",width1, height1),
                new VirKeyValue("9","Keypad9",width1, height1),
                new VirKeyValue("+","KeypadPlus",width1, height1),
            };
            dicVirKeys.Add(2, tempVirKeys);

            tempVirKeys = new List<VirKeyValue>
            {
                new VirKeyValue("Caps\nLock","Backspace", width120, height1),
                new VirKeyValue("A","A", width1, height1),
                new VirKeyValue("S","S", width1, height1),
                new VirKeyValue("D","D", width1, height1),
                new VirKeyValue("F","F", width1, height1),
                new VirKeyValue("G","G", width1, height1),
                new VirKeyValue("H","H", width1, height1),
                new VirKeyValue("J","J", width1, height1),
                new VirKeyValue("K","K", width1, height1),
                new VirKeyValue("L","L", width1, height1),
                new VirKeyValue(":\n;","Semicolon", width1, height1),
                new VirKeyValue("\"\n'","Quote", width1, height1),
                new VirKeyValue("Enter","Enter", 104, height1),
                new VirKeyValue("4","Keypad4",width1, height1),
                new VirKeyValue("5","Keypad5",width1, height1),
                new VirKeyValue("6","Keypad6",width1, height1),
                new VirKeyValue("Enter","KeypadEnter", width1, height1),
            };
            dicVirKeys.Add(3, tempVirKeys);

            tempVirKeys = new List<VirKeyValue>
            {
                new VirKeyValue("Shift","LeftShift", width140, height1),
                new VirKeyValue("Z","Z",width1, height1),
                new VirKeyValue("X","X",width1, height1),
                new VirKeyValue("C","C",width1, height1),
                new VirKeyValue("V","V",width1, height1),
                new VirKeyValue("B","B",width1, height1),
                new VirKeyValue("N","N",width1, height1),
                new VirKeyValue("M","M",width1, height1),
                new VirKeyValue("<\n,","Comma", width1, height1),
                new VirKeyValue(">\n.","Period", width1, height1),
                new VirKeyValue("?\n/","Slash", width1, height1),
                new VirKeyValue("Shift","RightControl", width140, height1),
                new VirKeyValue("↑","UpArrow", width1, height1),
                new VirKeyValue("1","Keypad1", width1, height1),
                new VirKeyValue("2","Keypad2", width1, height1),
                new VirKeyValue("3","Keypad3", width1, height1),
            };
            dicVirKeys.Add(4, tempVirKeys);

            tempVirKeys = new List<VirKeyValue>
            {
                new VirKeyValue("Ctrl","LeftControl", width2, height1),
                new VirKeyValue("Win", "LeftWindows",width1, height1),
                new VirKeyValue("Alt", "LeftAlt",width1, height1),
                new VirKeyValue("—————Space———","Space", width3, height1),
                new VirKeyValue("Alt", "RightAlt",width1, height1),
                new VirKeyValue("Ctrl", "RightControl",width2, height1),
                new VirKeyValue("←","LeftArrow",width1, height1),
                new VirKeyValue("↓","DownArrow",width1, height1),
                new VirKeyValue("→","RightArrow",width1, height1),
                new VirKeyValue("0","Keypad0",width100, height1),
                new VirKeyValue(".","KeypadPeriod",width1, height1),
            };
            dicVirKeys.Add(5, tempVirKeys);
        }
    }
    //用于繪制窗口內(nèi)容
    private void OnGUI()
    {
        DataInit();
        GUILayout.Label("Note:在開(kāi)發(fā)中會(huì)遇到使用監(jiān)控鍵盤(pán)輸入的情況,但是KeyCode的值往往分不清楚,此工具就是跟鍵盤(pán)一一對(duì)應(yīng)的Key值,不清楚的時(shí)候" +
            "看一眼就行了,當(dāng)然,也可以點(diǎn)擊按鈕,點(diǎn)擊后可以打印當(dāng)前KeyCode值。");
        for (int i = 0; i < dicVirKeys.Count; i++)
        {
            GUILayout.BeginVertical();
            OnRow(i);
            GUILayout.EndVertical();
        }
    }

    void OnRow(int index)
    {
        GUILayout.BeginHorizontal();
        for (int i = 0; i < dicVirKeys[index].Count; i++)
        {
            if (dicVirKeys[index][i].name == "↑")
            {
                GUILayout.Space(50);
            }
            else if (dicVirKeys[index][i].name == "←")
            {
                GUILayout.Space(180);
            }
            else if (dicVirKeys[index][i].name == "4")
            {
                GUILayout.Space(160);
            }
            else if (dicVirKeys[index][i].name == "1")
            {
                GUILayout.Space(60);
            }
            else if (dicVirKeys[index][i].name == "0")
            {
                GUILayout.Space(6);
            }
            GUILayout.BeginVertical();

            if (GUILayout.Button(dicVirKeys[index][i].name, GUILayout.Width(dicVirKeys[index][i].width), GUILayout.Height(dicVirKeys[index][i].height)))
            {
                Debug.Log("當(dāng)前按下的鍵位是 : KeyCode." + dicVirKeys[index][i].key);
            }
            GUILayout.Label(dicVirKeys[index][i].key);
            GUILayout.EndVertical();
            if (dicVirKeys[index][i].name == "Esc")
            {
                GUILayout.Space(52);
            }
            else if (dicVirKeys[index][i].name == "F4")
            {
                GUILayout.Space(36);
            }
            else if (dicVirKeys[index][i].name == "F8")
            {
                GUILayout.Space(36);
            }
        }
        GUILayout.EndHorizontal();
    }
}

然后在Untiy編輯器的Edit欄,選擇工具→鍵盤(pán)映射值打開(kāi)面板:
【Unity3D編輯器開(kāi)發(fā)】Unity3D中實(shí)現(xiàn)查看鍵盤(pán)對(duì)應(yīng)KeyCode值面板【方便開(kāi)發(fā)】,# Unity3D之編輯器擴(kuò)展,編輯器,計(jì)算機(jī)外設(shè),c#,unity

三、后記

如果覺(jué)得本篇文章有用別忘了點(diǎn)個(gè)關(guān)注,關(guān)注不迷路,持續(xù)分享更多Unity干貨文章。


你的點(diǎn)贊就是對(duì)博主的支持,有問(wèn)題記得留言:

博主主頁(yè)有聯(lián)系方式。

博主還有跟多寶藏文章等待你的發(fā)掘哦:文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-714638.html

專欄 方向 簡(jiǎn)介
Unity3D開(kāi)發(fā)小游戲 小游戲開(kāi)發(fā)教程 分享一些使用Unity3D引擎開(kāi)發(fā)的小游戲,分享一些制作小游戲的教程。
Unity3D從入門(mén)到進(jìn)階 入門(mén) 從自學(xué)Unity中獲取靈感,總結(jié)從零開(kāi)始學(xué)習(xí)Unity的路線,有C#和Unity的知識(shí)。
Unity3D之UGUI UGUI Unity的UI系統(tǒng)UGUI全解析,從UGUI的基礎(chǔ)控件開(kāi)始講起,然后將UGUI的原理,UGUI的使用全面教學(xué)。
Unity3D之讀取數(shù)據(jù) 文件讀取 使用Unity3D讀取txt文檔、json文檔、xml文檔、csv文檔、Excel文檔。
Unity3D之?dāng)?shù)據(jù)集合 數(shù)據(jù)集合 數(shù)組集合:數(shù)組、List、字典、堆棧、鏈表等數(shù)據(jù)集合知識(shí)分享。
Unity3D之VR/AR(虛擬仿真)開(kāi)發(fā) 虛擬仿真 總結(jié)博主工作常見(jiàn)的虛擬仿真需求進(jìn)行案例講解。
Unity3D之插件 插件 主要分享在Unity開(kāi)發(fā)中用到的一些插件使用方法,插件介紹等
Unity3D之日常開(kāi)發(fā) 日常記錄 主要是博主日常開(kāi)發(fā)中用到的,用到的方法技巧,開(kāi)發(fā)思路,代碼分享等
Unity3D之日常BUG 日常記錄 記錄在使用Unity3D編輯器開(kāi)發(fā)項(xiàng)目過(guò)程中,遇到的BUG和坑,讓后來(lái)人可以有些參考。

到了這里,關(guān)于【Unity3D編輯器開(kāi)發(fā)】Unity3D中實(shí)現(xiàn)查看鍵盤(pán)對(duì)應(yīng)KeyCode值面板【方便開(kāi)發(fā)】的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 【Unity3D】Unity 腳本 ② ( Visual Studio 2019 中的 Unity 編譯環(huán)境配置 | Unity 編輯器關(guān)聯(lián)外部 C# 腳本編輯器 Visual Studio )

    【Unity3D】Unity 腳本 ② ( Visual Studio 2019 中的 Unity 編譯環(huán)境配置 | Unity 編輯器關(guān)聯(lián)外部 C# 腳本編輯器 Visual Studio )

    在上一篇博客 【Unity3D】Unity 腳本 ① ( 創(chuàng)建 C# 腳本 | Visual Studio 2019 中打開(kāi) C# 腳本 | 編譯 C# 腳本 | 掛載 C# 腳本到游戲物體 | 運(yùn)行腳本 ) 中 , 雙擊 Unity 編輯器中的 Project 窗口中的 C# 腳本 , 進(jìn)入到 Visual Studio 中出現(xiàn)下圖樣式 , 這是因?yàn)闆](méi)有配置 Unity 編譯環(huán)境 ; 參考如下兩個(gè)博

    2023年04月08日
    瀏覽(101)
  • Unity3d C#利用Editor編輯器拓展實(shí)現(xiàn)配置UI背景樣式一鍵設(shè)置UI背景樣式功能(含源碼)

    Unity3d C#利用Editor編輯器拓展實(shí)現(xiàn)配置UI背景樣式一鍵設(shè)置UI背景樣式功能(含源碼)

    在開(kāi)發(fā)UI滾動(dòng)列表的時(shí)候,經(jīng)常會(huì)有每項(xiàng)的背景圖不統(tǒng)一的情況,會(huì)間隔重復(fù)的情況居多。這種情況下,手動(dòng)去設(shè)置間隔一行的背景圖或者顏色是比較麻煩的。在此背景下,筆者嘗試寫(xiě)個(gè)小工具,在搭建UI時(shí)配置一下循環(huán)背景的樣式,可以通過(guò)一鍵點(diǎn)擊后設(shè)置UI背景的樣式,省

    2024年02月03日
    瀏覽(29)
  • 【Unity3D日常開(kāi)發(fā)】Unity3D中實(shí)現(xiàn)單例模式詳解

    【Unity3D日常開(kāi)發(fā)】Unity3D中實(shí)現(xiàn)單例模式詳解

    推薦閱讀 CSDN主頁(yè) GitHub開(kāi)源地址 Unity3D插件分享 簡(jiǎn)書(shū)地址 我的個(gè)人博客 大家好,我是佛系工程師 ☆恬靜的小魔龍☆ ,不定時(shí)更新Unity開(kāi)發(fā)技巧,覺(jué)得有用記得一鍵三連哦。 首先,說(shuō)一下,什么是 單例模式(Singleton) 。 單例模式是設(shè)計(jì)模式中常見(jiàn)的一種設(shè)計(jì)模式,目的是為了

    2024年02月02日
    瀏覽(29)
  • 【Unity3D日常開(kāi)發(fā)】Unity3D中實(shí)現(xiàn)不同腳本之間的執(zhí)行順序控制

    【Unity3D日常開(kāi)發(fā)】Unity3D中實(shí)現(xiàn)不同腳本之間的執(zhí)行順序控制

    推薦閱讀 CSDN主頁(yè) GitHub開(kāi)源地址 Unity3D插件分享 簡(jiǎn)書(shū)地址 我的個(gè)人博客 大家好,我是佛系工程師 ☆恬靜的小魔龍☆ ,不定時(shí)更新Unity開(kāi)發(fā)技巧,覺(jué)得有用記得一鍵三連哦。 首先,來(lái)了解一下事件函數(shù)的執(zhí)行順序,下圖是官方給的腳本中事件函數(shù)的執(zhí)行順序: 眾所周知,U

    2024年02月02日
    瀏覽(36)
  • 【Unity3D小功能】Unity3D中實(shí)現(xiàn)Text顯示版本功能

    【Unity3D小功能】Unity3D中實(shí)現(xiàn)Text顯示版本功能

    推薦閱讀 CSDN主頁(yè) GitHub開(kāi)源地址 Unity3D插件分享 簡(jiǎn)書(shū)地址 我的個(gè)人博客 大家好,我是佛系工程師 ☆恬靜的小魔龍☆ ,不定時(shí)更新Unity開(kāi)發(fā)技巧,覺(jué)得有用記得一鍵三連哦。 在項(xiàng)目開(kāi)發(fā)中,會(huì)遇到要控制版本的情況,比如說(shuō)對(duì)比版本號(hào),版本不對(duì)再更新版本的功能,這些就是

    2024年02月05日
    瀏覽(99)
  • 【Unity3D小功能】Unity3D中實(shí)現(xiàn)點(diǎn)擊‘文字’出現(xiàn)‘UI面板’

    【Unity3D小功能】Unity3D中實(shí)現(xiàn)點(diǎn)擊‘文字’出現(xiàn)‘UI面板’

    推薦閱讀 CSDN主頁(yè) GitHub開(kāi)源地址 Unity3D插件分享 簡(jiǎn)書(shū)地址 QQ群:398291828 大家好,我是佛系工程師 ☆恬靜的小魔龍☆ ,不定時(shí)更新Unity開(kāi)發(fā)技巧,覺(jué)得有用記得一鍵三連哦。 寵粉博主又來(lái)了,今天有粉絲問(wèn)我如何實(shí)現(xiàn)點(diǎn)擊一段文字然后出現(xiàn)的面板在那段文字附近顯示: 深入了

    2024年04月13日
    瀏覽(167)
  • 【Unity3D小功能】Unity3D中實(shí)現(xiàn)仿真時(shí)鐘、表盤(pán)、仿原神時(shí)鐘

    【Unity3D小功能】Unity3D中實(shí)現(xiàn)仿真時(shí)鐘、表盤(pán)、仿原神時(shí)鐘

    推薦閱讀 CSDN主頁(yè) GitHub開(kāi)源地址 Unity3D插件分享 簡(jiǎn)書(shū)地址 我的個(gè)人博客 大家好,我是佛系工程師 ☆恬靜的小魔龍☆ ,不定時(shí)更新Unity開(kāi)發(fā)技巧,覺(jué)得有用記得一鍵三連哦。 今天實(shí)現(xiàn)一個(gè)時(shí)鐘工具,其實(shí)在之前已經(jīng)完成了一個(gè)簡(jiǎn)單的時(shí)鐘工具:【Unity3D應(yīng)用案例系列】時(shí)鐘、

    2024年02月05日
    瀏覽(27)
  • 【Unity3D小功能】Unity3D中實(shí)現(xiàn)UI擦除效果、刮刮卡功能

    【Unity3D小功能】Unity3D中實(shí)現(xiàn)UI擦除效果、刮刮卡功能

    推薦閱讀 CSDN主頁(yè) GitHub開(kāi)源地址 Unity3D插件分享 簡(jiǎn)書(shū)地址 我的個(gè)人博客 大家好,我是佛系工程師 ☆恬靜的小魔龍☆ ,不定時(shí)更新Unity開(kāi)發(fā)技巧,覺(jué)得有用記得一鍵三連哦。 使用Unity3D實(shí)現(xiàn)UI的擦拭效果、刮刮卡功能的效果實(shí)現(xiàn)方式比較多,比如說(shuō)用Shader、Texture渲染都是可以

    2024年02月04日
    瀏覽(158)
  • Unity3D中實(shí)現(xiàn)動(dòng)畫(huà)的方式:

    Unity3D中實(shí)現(xiàn)動(dòng)畫(huà)的方式有很多種,以下是其中兩種常用的方式: 1. 使用Animation組件 使用Animation組件可以制作簡(jiǎn)單的關(guān)鍵幀動(dòng)畫(huà)。步驟如下: 將需要?jiǎng)赢?huà)的物體選中,然后在Inspector面板中點(diǎn)擊Add Component按鈕,選擇Animation組件。 在Project面板中創(chuàng)建動(dòng)畫(huà)剪輯(Animation Clip)。

    2024年02月08日
    瀏覽(26)
  • Unity3D中實(shí)現(xiàn)Player的第一人稱視角

    Unity3D中實(shí)現(xiàn)Player的第一人稱視角

    效果,上面為Scene場(chǎng)景,下面為Game場(chǎng)景 0創(chuàng)建地形,當(dāng)然可以先簡(jiǎn)單的創(chuàng)建一個(gè)空白的Terrain。這里我已經(jīng)對(duì)地形進(jìn)行了初步的編輯和渲染。 1.在Hierarchy視圖中右鍵創(chuàng)建一個(gè)膠囊體(Capsule)作為Player,添加好后重置膠囊體的位置,并且調(diào)整膠囊體在一個(gè)合適的位置。 ?2.將Main

    2023年04月08日
    瀏覽(30)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包