Virtual buttons
IntermediateProgrammer virtual buttons. Players can then assign physical buttons to the virtual buttons, allowing them to create their own control schemes. UseMedkit function. Rather than bind the function to a particular key, you can create a virtual button called UseMedkit, then bind the virtual button to, say, the F key. If they want to, the player can then bind the virtual key to a different key at runtime.
Use virtual buttons
- MyButton).
- MyButton to the list of virtual buttons.
- MyButton.
- -
Example code
public override void Start(){ base.Start(); // Create a new VirtualButtonConfigSet if none exists. Input.VirtualButtonConfigSet = Input.VirtualButtonConfigSet ?? new VirtualButtonConfigSet(); //Bind "M" key, GamePad "Start" button and left mouse button to a virtual button "MyButton". VirtualButtonBinding b1 = new VirtualButtonBinding("MyButton", VirtualButton.Keyboard.M); VirtualButtonBinding b2 = new VirtualButtonBinding("MyButton", VirtualButton.GamePad.Start); VirtualButtonBinding b3 = new VirtualButtonBinding("MyButton", VirtualButton.Mouse.Left); VirtualButtonConfig c = new VirtualButtonConfig(); c.Add(b1); c.Add(b2); c.Add(b3); Input.VirtualButtonConfigSet.Add(c);}public override void Update() { float button = Input.GetVirtualButton(0, "MyButton");}
See also
- Gamepads
- Keyboard
- Mouse
- Pointers
- Input overview
