UnityのWebGLビルドした際のJoyStic情報

使用ライセンス

Safariでは動作するようです。

        
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;

namespace SyskenTLib.SimpleFunction1.Gamepad
{
    public class ShowCurrentPadLog : MonoBehaviour
    {
        [SerializeField] private TextMeshProUGUI _targetTMPLabel;


        // Update is called once per frame
        void Update()
        {
            if (_targetTMPLabel != null)
            {
                _targetTMPLabel.text = GetTargetTxt();

            }
        }


        public virtual string GetTargetTxt()
        {
            if (UnityEngine.InputSystem.Gamepad.current == null)
            {
                return "None GamePad";
            }

            string targetTxt = "";
            targetTxt += "leftStick:" +UnityEngine.InputSystem.Gamepad.current.leftStick.ReadValue().ToString()+"\n";
            targetTxt += "leftStickButton:" +UnityEngine.InputSystem.Gamepad.current.leftStickButton.isPressed.ToString()+"\n\n";

            targetTxt += "rightStick:" +UnityEngine.InputSystem.Gamepad.current.rightStick.ReadValue().ToString()+"\n";
            targetTxt += "rightStickButton:" +UnityEngine.InputSystem.Gamepad.current.rightStickButton.isPressed.ToString()+"\n\n";

            targetTxt += "leftTrigger:" +UnityEngine.InputSystem.Gamepad.current.leftTrigger.ReadValue().ToString()+"\n";
            targetTxt += "leftShoulder:" +UnityEngine.InputSystem.Gamepad.current.leftShoulder.ReadValue().ToString()+"\n\n";

            targetTxt += "rightTrigger:" +UnityEngine.InputSystem.Gamepad.current.rightTrigger.ReadValue().ToString()+"\n";
            targetTxt += "rightShoulder:" +UnityEngine.InputSystem.Gamepad.current.rightShoulder.ReadValue().ToString()+"\n\n";

            targetTxt += "buttonNorth:" +UnityEngine.InputSystem.Gamepad.current.buttonNorth.isPressed.ToString()+"\n";
            targetTxt += "buttonEast:" +UnityEngine.InputSystem.Gamepad.current.buttonEast.isPressed.ToString()+"\n";
            targetTxt += "buttonSouth:" +UnityEngine.InputSystem.Gamepad.current.buttonSouth.isPressed.ToString()+"\n";
            targetTxt += "buttonWest:" +UnityEngine.InputSystem.Gamepad.current.buttonWest.isPressed.ToString()+"\n\n";


            targetTxt += "startButton:" +UnityEngine.InputSystem.Gamepad.current.startButton.isPressed.ToString()+"\n";







            return targetTxt;
        }

    }
}



        
            

広告

【PS5】ストリートファイター6 【SONYライセンス商品】STREET FIGHTER™6 ファイティングスティックα for PlayStationⓇ5,PlayStationⓇ4,PC【PS5,PS4両対応】 【Amazon.co.jp限定】 アサヒ飲料 MS+B ウィルキンソン タンサン ラベルレスボトル 500ml×24本 [炭酸水] 玄人志向 USB3.2 Gen2 接続 2.5型 SSD / HDD ドライブケース GW2.5AM-SU3G2

作者について © 2019 SakumaKatsuya(@ppengotsu)