using UnityEngine; using UnityEngine.UI; using UnityStandardAssets.CrossPlatformInput; public class ButtonController : MonoBehaviour { public GameObject player; public Button jumpButton; private void Update() { if (CrossPlatformInputManager.GetButton("Jump")) { player.GetComponent().Jump(); } } }
using UnityEngine; using UnityStandardAssets.CrossPlatformInput; public class FireController : MonoBehaviour { public GameObject bulletPrefab; public Transform firePoint; private void Update() { if (CrossPlatformInputManager.GetButton("Fire1")) { Fire(); } } void Fire() { Instantiate(bulletPrefab, firePoint.position, firePoint.rotation); } }This example uses `GetButton` to detect if the "Fire1" button is being pressed. If it is, we call the `Fire()` function to instantiate a bullet prefab from the `firePoint` position and rotation. In both examples, we are using the `CrossPlatformInputManager` package library to manage the player's inputs.