diff --git a/Docs/VS_Scratch_Mapping.md b/Docs/VS_Scratch_Mapping.md index 6cf49de..55c419d 100644 --- a/Docs/VS_Scratch_Mapping.md +++ b/Docs/VS_Scratch_Mapping.md @@ -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 | diff --git a/Runtime/Integrations/VisualScripting/Units/ScratchUnits/InputPredicateUnits.cs b/Runtime/Integrations/VisualScripting/Units/ScratchUnits/InputPredicateUnits.cs index f7ac909..6726322 100644 --- a/Runtime/Integrations/VisualScripting/Units/ScratchUnits/InputPredicateUnits.cs +++ b/Runtime/Integrations/VisualScripting/Units/ScratchUnits/InputPredicateUnits.cs @@ -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 @@ -94,51 +95,51 @@ private static bool IsPressedByInputSystem(KeyCode keyCode) /// 変換元の KeyCode。 /// 変換に成功した場合の出力先。 /// 変換できた場合は true。それ以外は false。 - 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;