Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Docs/VS_Scratch_Mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Scratch ブロックと FUnity 独自 Visual Scripting Unit の対応関係で
## 調べる
| Scratch ブロック (日本語) | FUnity Unit クラス | UnitTitle | UnitCategory | 備考 |
| --- | --- | --- | --- | --- |
| ○キーが押された? | FUnity.Runtime.Integrations.VisualScripting.Units.ScratchUnits.KeyIsPressedUnit | ○キーが押された? | FUnity/Scratch/調べる | Input System 有効時は `Keyboard.current` で押下判定し、無効時は `UnityEngine.Input.GetKey` を使用。未対応キーや Keyboard が null の場合は false。定義: Runtime/.../InputPredicateUnits.cs |
| ○キーが押された? | FUnity.Runtime.Integrations.VisualScripting.Units.ScratchUnits.KeyIsPressedUnit | ○キーが押された? | FUnity/Scratch/調べる | Input System 有効時は `Keyboard.current` で押下判定し、無効時は `UnityEngine.Input.GetKey` を使用。Input System の Key enum は `InputSystemKey` エイリアス経由で参照し、Unit 側の `Key` プロパティと衝突しないようにしている。未対応キーや Keyboard が null の場合は false。定義: Runtime/.../InputPredicateUnits.cs |
| マウスのx座標 | FUnity.Runtime.Integrations.VisualScripting.Units.ScratchUnits.Probe.MouseXUnit | マウスのx座標 | FUnity/Scratch/調べる | ステージ中心原点でのマウス x 座標。定義: Runtime/.../Probe/MouseXUnit.cs |
| マウスのy座標 | FUnity.Runtime.Integrations.VisualScripting.Units.ScratchUnits.Probe.MouseYUnit | マウスのy座標 | FUnity/Scratch/調べる | ステージ中心原点でのマウス y 座標。定義: Runtime/.../Probe/MouseYUnit.cs |
| マウスポインターに触れた? | FUnity.Runtime.Integrations.VisualScripting.Units.ScratchUnits.TouchingMousePointerPredicateUnit | マウスポインターに触れた? | FUnity/Scratch/調べる | 俳優矩形とマウス座標を判定。定義: Runtime/.../TouchPredicates.cs |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using UInput = UnityEngine.Input;
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem;
using InputSystemKey = UnityEngine.InputSystem.Key;
#endif

namespace FUnity.Runtime.Integrations.VisualScripting.Units.ScratchUnits
Expand Down Expand Up @@ -94,51 +95,51 @@ private static bool IsPressedByInputSystem(KeyCode keyCode)
/// <param name="keyCode">変換元の KeyCode。</param>
/// <param name="inputSystemKey">変換に成功した場合の出力先。</param>
/// <returns>変換できた場合は true。それ以外は false。</returns>
private static bool TryMapKeyCodeToInputSystemKey(KeyCode keyCode, out Key inputSystemKey)
private static bool TryMapKeyCodeToInputSystemKey(KeyCode keyCode, out InputSystemKey inputSystemKey)
{
if (keyCode >= KeyCode.A && keyCode <= KeyCode.Z)
{
inputSystemKey = (Key)((int)Key.A + ((int)keyCode - (int)KeyCode.A));
inputSystemKey = (InputSystemKey)((int)InputSystemKey.A + ((int)keyCode - (int)KeyCode.A));
return true;
}

if (keyCode >= KeyCode.Alpha0 && keyCode <= KeyCode.Alpha9)
{
inputSystemKey = (Key)((int)Key.Digit0 + ((int)keyCode - (int)KeyCode.Alpha0));
inputSystemKey = (InputSystemKey)((int)InputSystemKey.Digit0 + ((int)keyCode - (int)KeyCode.Alpha0));
return true;
}

if (keyCode >= KeyCode.Keypad0 && keyCode <= KeyCode.Keypad9)
{
inputSystemKey = (Key)((int)Key.Numpad0 + ((int)keyCode - (int)KeyCode.Keypad0));
inputSystemKey = (InputSystemKey)((int)InputSystemKey.Numpad0 + ((int)keyCode - (int)KeyCode.Keypad0));
return true;
}

switch (keyCode)
{
case KeyCode.Space:
inputSystemKey = Key.Space;
inputSystemKey = InputSystemKey.Space;
return true;
case KeyCode.LeftArrow:
inputSystemKey = Key.LeftArrow;
inputSystemKey = InputSystemKey.LeftArrow;
return true;
case KeyCode.RightArrow:
inputSystemKey = Key.RightArrow;
inputSystemKey = InputSystemKey.RightArrow;
return true;
case KeyCode.UpArrow:
inputSystemKey = Key.UpArrow;
inputSystemKey = InputSystemKey.UpArrow;
return true;
case KeyCode.DownArrow:
inputSystemKey = Key.DownArrow;
inputSystemKey = InputSystemKey.DownArrow;
return true;
case KeyCode.Return:
inputSystemKey = Key.Enter;
inputSystemKey = InputSystemKey.Enter;
return true;
case KeyCode.KeypadEnter:
inputSystemKey = Key.NumpadEnter;
inputSystemKey = InputSystemKey.NumpadEnter;
return true;
case KeyCode.Escape:
inputSystemKey = Key.Escape;
inputSystemKey = InputSystemKey.Escape;
return true;
default:
inputSystemKey = default;
Expand Down