补充示例
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* UniWindowController 的示例脚本
|
||||
* A sample script of UniWindowContoller
|
||||
*
|
||||
* 作者: Kirurobo http://twitter.com/kirurobo
|
||||
* 许可证: MIT
|
||||
* Author: Kirurobo http://twitter.com/kirurobo
|
||||
* License: MIT
|
||||
*/
|
||||
|
||||
using System;
|
||||
@@ -15,8 +15,8 @@ using UnityEngine.InputSystem;
|
||||
|
||||
namespace Kirurobo {
|
||||
/// <summary>
|
||||
/// 用于消除 Input System 和 Input Manager 差异的代理
|
||||
/// </summary>
|
||||
/// Input System と Input Manager の違いを吸収するためのプロキシ
|
||||
/// </summary>
|
||||
public class InputProxy
|
||||
{
|
||||
public static Vector3 mousePosition {
|
||||
@@ -26,7 +26,7 @@ namespace Kirurobo {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 配合 Input System 获取按键抬起
|
||||
/// Input System の利用に合わせてキーアップを取得
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static bool GetKeyUp(String key)
|
||||
@@ -34,22 +34,22 @@ namespace Kirurobo {
|
||||
#if ENABLE_LEGACY_INPUT_MANAGER
|
||||
return Input.GetKeyUp(key);
|
||||
#elif ENABLE_INPUT_SYSTEM
|
||||
// 简易实现。仅支持单字母字符或数字
|
||||
// 非单字符的仅支持 escape, space
|
||||
// 簡易的な実装。keyが1文字で、かつアルファベットか数字に対応
|
||||
// 1文字以外は escape, space のみ対応
|
||||
if (key.Length == 1) {
|
||||
Key k = Key.None;
|
||||
char c = key[0];
|
||||
if (c >= '0' && c <= '9') {
|
||||
// 数字时同时响应 Digit0~Digit9 和 Numpad0~Numpad9
|
||||
// 数字の場合はDigit0~Digit9とNumpad0~Numpad9の両方に反応
|
||||
k = (Key)Enum.ToObject(typeof(Key), (int)Key.Numpad0 + (int)(c - '0'));
|
||||
if (Keyboard.current[k].wasReleasedThisFrame) return true;
|
||||
|
||||
// Digit 键中 Digit0 的数值最大
|
||||
// Digitの場合はDigit0の値が最大
|
||||
k = (Key)Enum.ToObject(typeof(Key), (int)Key.Digit1 + (int)((c == '0' ? 9 : c - '1')));
|
||||
if (Keyboard.current[k].wasReleasedThisFrame) return true;
|
||||
}
|
||||
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) {
|
||||
// 字母时大小写均可
|
||||
// アルファベットの場合は大文字・小文字どちらでも可とする
|
||||
k = (Key)Enum.ToObject(typeof(Key), (int)Key.A + (int)(Char.ToUpper(c) - 'A'));
|
||||
if (Keyboard.current[k].wasReleasedThisFrame) return true;
|
||||
}
|
||||
@@ -65,7 +65,7 @@ namespace Kirurobo {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 配合 Input System 获取鼠标坐标
|
||||
/// Input System の利用に合わせてマウス座標を取得
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static Vector3 GetMousePosition()
|
||||
@@ -80,7 +80,7 @@ namespace Kirurobo {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断鼠标按钮当前是否被按下
|
||||
/// マウスボタンが現在押されているか判定
|
||||
/// </summary>
|
||||
/// <param name="button"></param>
|
||||
/// <returns></returns>
|
||||
@@ -99,7 +99,7 @@ namespace Kirurobo {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断本帧是否按下了鼠标按钮
|
||||
/// このフレームでマウスボタンが押されたか判定
|
||||
/// </summary>
|
||||
/// <param name="button"></param>
|
||||
/// <returns></returns>
|
||||
@@ -118,7 +118,7 @@ namespace Kirurobo {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断本帧是否松开了鼠标按钮
|
||||
/// このフレームでマウスボタンが離されたか判定
|
||||
/// </summary>
|
||||
/// <param name="button"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
Reference in New Issue
Block a user