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;
        }

    }
}



        
            



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