JU Input Manager

The JU Input Manager helps with input handling and cross-platform operation.

Simple Input Detection

This page will be useful when you want to expand the system, add actions or just detect inputs.

Using the JU Input Manager to detect inputs is simple, inspired by the old input system:

using UnityEngine;

// 1 Step -> Import JUInputSystem
using JUTPS.JUInputSystem;

public class JUInputHandlingTest : MonoBehaviour
{
    void Update()
    {
        // 2 Step -> Check if Jump Button(Space Default) was pressed
        if (JUInput.GetButtonDown(JUInput.Buttons.JumpButton))
        {
            Debug.Log("Pressed Jump");
        }
    }
}

In line 4 the JUInputSystem is imported, in line 11 the check is made if the jump button was pressed, and in line 13 it is an example of action that can be replaced by any other code.

Functions and Description

FunctionSummary

float GetAxis(Axis axis)

Returns the value of the deafult axis

bool GetButtonDown(Buttons Button)

Returns the value of the deafult buttons when pressed down

bool GetButton(Buttons Button)

Returns the value of the deafult buttons when pressed

GetButtonUp(Buttons Button)

Returns the value of the deafult buttons when pressed up

bool GetCustomButton(string CustomButtonName)

Returns the value of the custom buttons when pressed

bool GetCustomButtonDown(string CustomButtonName)

Returns the value of the custom buttons when pressed down

bool GetCustomButtonUp(string CustomButtonName)

Returns the value of the custom buttons when pressed up

bool GetCustomTouchButton(string CustomButtonName)

Returns the value of the custom touch buttons when pressed

bool GetCustomTouchButtonDown(string CustomButtonName)

Returns the value of the custom touch buttons when pressed down

bool GetCustomTouchButtonUp(string CustomButtonName)

Returns the value of the custom touch buttons when pressed up

Vector2 GetCustomTouchfieldAxis(string CustomTouchfield)

Returns the value of the custom Touchfield

Vector2 GetCustomVirtualJoystickAxis(string CustomJoystickName)

Returns the value of the custom Joystick

Vector2 GetMousePosition()

Return current mouse position

int GetTouchsLengh()

Returns the number of touches on the screen

InputSystem.Controls.TouchControl[] GetTouches()

EnumsContent

Axis

MoveHorizontal, MoveVertical, RotateHorizontal, RotateVertical

Buttons

ShotButton, AimingButton, JumpButton, RunButton, PunchButton, RollButton, CrouchButton, ProneButton, ReloadButton, PickupButton, EnterVehicleButton, PreviousWeaponButton, NextWeaponButton, OpenInventory

The Enums above are all default JU TPS Inputs that you can easily access with the above functions.

Example: float moveHorizontal = JUInput.GetAxis(JUInput.Axis.MoveHorizontal);

Custom Inputs

In the JU Input Manager you can create custom inputs and call it normally, first create a Custom Input:

Note that the "Custom Button" only works in the Old Input System, if you want to check inputs in the new input system you can use Input Events Components

And you can call that input like this:

 //Check if Custom Button "SuperPower" was pressed
if (JUInput.GetCustomButtonDown("SuperPower") || JUInput.GetCustomTouchButtonDown("SuperPower"))
{
   Debug.Log("Pressed M");
}

See below all Custom Input Functions:

FunctionsSummary

bool GetCustomButton(string CustomButtonName)

Returns the value of the custom Input Button when pressed

bool GetCustomButtonDown(string CustomButtonName)

Returns the value of the custom Input Button when pressed Down

bool GetCustomButtonUp(string CustomButtonName)

Returns the value of the custom Input Button when pressed up

GetCustomTouchButton(string CustomButtonName)

Returns the value of the custom Virtual Button when pressed

GetCustomTouchButtonDown(string CustomButtonName)

Returns the value of the custom Virtual Button when pressed down

bool GetCustomTouchButtonUp(string CustomButtonName)

Returns the value of the custom Virtual Button when pressed up

Vector2 GetCustomTouchfieldAxis(string CustomTouchfield)

Returns the value of the custom Touchfield

Vector2 GetCustomVirtualJoystickAxis(string CustomJoystickName)

Returns the value of the custom Joystick

Rewrite Functions

These functions rewrite the Inputs, it is used by Mobile Rig to make the virtual buttons work.

FunctionsSummary

RewriteInputAxis(Axis axis, float AxisValue)

Rewrite the value of a default JU input axis

RewriteInputButtonPressed(Buttons button, bool ButtonValue)

Rewrite the value of a default JU input button

RewriteInputButtonPressedDown(Buttons button, bool ButtonValue)

Rewrite the value of a default JU input button

RewriteInputButtonPressedUp(Buttons button, bool ButtonValue)

Rewrite the value of a default JU input button

Last updated