上次做了个笔记是关于调用windows系统自带的触摸键盘的方法:C#调用Windows系统自带触摸键盘的方法_c# 虚拟键盘-优快云博客
除了调用触摸键盘,我们也可以通过调用win10的自带软键盘作为输入途径。
方法很简单。
1、添加using System.Diagnostics引用。
2、创建进程Process Winvirkey = Process.Start("osk.exe");
3、打开键盘:Winvirkey = Process.Start("osk.exe");
4、关闭键盘:Winvirkey.Kill();
具体实现如下:
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;
public class Win10key : MonoBehaviour
{
Process Winvirkey;
// Start is called before the first frame update
void Start()
{
Winvirkey = Process.Start("osk.exe");
Winvirkey.Kill();
}
// Update is called once per frame
void Update()
{
if(Input.GetKeyDown(KeyCode.F1))
{
ShowKey();
}
else if(Input.GetKeyDown(KeyCode.F2))

本文介绍了如何使用C#在Unity游戏开发中调用Windows10的自带软键盘,包括启动、显示和关闭键盘的过程,以及代码示例。
最低0.47元/天 解锁文章
720

被折叠的 条评论
为什么被折叠?



