Unity Input SystemのCallBackContextからPlayerIDを取得したい

Unity2021のInputSystem1.4.3で、CallbackContextを引数にしたメソッドを使っています。
サンプルのPlayerInputとPlayerInputManagerを使用して、ローカルマルチプレイヤーも設定しています。

プレイヤー以外のGameObjectで、InputのEventをリスナーしたい要件が出たため、以下のようにCallbackContextを使用したメソッドを作りました。
CallBackContextからPlayerのID(1Pは0、2Pは1)を取得したいのですが、どこにあるのでしょうか。

PlayerInputではUserIDとしてインスペクタのDebugという項目に出ていますが、CallbackContextからの取得方法が分かりません。
デバッグモードでのローカルウインドウ、ソース、ドキュメント、UnityForumや英文でもググったりなどかなり探しましたが見つかりません。
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.4/api/UnityEngine.InputSystem.InputAction.CallbackContext.html?q=CallbackContext
また、このような見つからない場合、どのようにすれば効率よく探し出せる、存在しない、などを判断出来るのでしょうか?
見つかるまで延々と探してしまいます。

using System.Linq; using UniRx; using UnityEngine; using UnityEngine.InputSystem; using static UnityEngine.InputSystem.InputAction; public class HUDRestaurantStartReadyComplete : MonoBehaviour { public UnityEngine.InputSystem.InputActionReference inputActionReference; private void Start() { inputActionReference.action.performed += ReadyRestaurant; PlayerInputManager.instance.onPlayerJoined += OnJoinPlayer; } private void OnJoinPlayer(PlayerInput obj) { var readyAction = obj.actions[inputActionReference.name]; readyAction.performed += ReadyRestaurant; //inputActionReference.action.performed += ReadyRestaurant; } private void OnDisable() { //readyAction.Disable(); inputActionReference.action.performed -= ReadyRestaurant; } private void ReadyRestaurant(CallbackContext callbackContext) { Debug.Log("ReadySale inputID:" + callbackContext.control.device.deviceId + " name:" + callbackContext.control.displayName); // deviceidは1Pが7、2Pが4と、よく分からない数値が返る Debug.Log("1PはID:0、2PはID:1を返す値がcallbackContextから欲しいが見つからない"); } }

コメントを投稿

0 コメント