Giter VIP home page Giter VIP logo

inputsystemmanager's Introduction

Input System Manager

This asset for Unity is a powerful Input System Manager that allows you to easily retrieve data from the Input System using Scriptable Objects as references to Input Actions. With this Singleton-based solution, you'll be able to speed up the process of game development and create a more intuitive user experience for your players.

Features

  • Singleton/Instance based script for easy global access.
  • Plug'n'Play, just add your Input Action Asset and references to the Manager and start reading inputs!
  • Key rebinding support.
  • 2 methods to read inputs: Scriptable Objects and Strings!
  • Simple one-line code to read any inputs.
  • Perfect for Single-Player and Networked Multiplayer.

Limitations

  • Local Multiplayer/Split-Screen is not supported.
  • Only one Action Map is supported.

Installation

  1. Download the asset and import to your Project.
  2. Create a new Empty Game Object and add the InputManager.cs component to it.
  3. Create and configure a new Input Actions Asset. (Don't forget to install the Input System package from the Package Manager).
  4. Drag and Drop or Select the Input Actions Asset in the InputManager component.
  5. Create reference/s for the asset clicking Create > Scriptable Objects > Input Manager > InputActionReference, providing the Name and the Type of the Action.
  6. Add the reference/s to the Input Manager component's array.
  7. That's all. Now you can retrieve data from the actions by calling code from the InputManager's Instance.

How to Use

You can retrieve data from the Input System Manager by using one of the 2 types as a reference.

By Input Action References

public InputActionReference moveActionReference; // Vector2
public InputActionReference shootActionReference; // Button

private void Update() {
    if(InputManager.Instance.GetInputActionValue(moveActionReference, out Vector2 moveInputValue)) {
        // Movement Code
    }

    if(InputManager.Instance.GetInputActionValue(shootActionReference, InputActionState.WasPressedThisFrame)) {
        // Shooting Code
    }
}

By Strings

private void Update() {
    if(InputManager.Instance.GetInputActionValue("Movement", out Vector2 moveInputValue)) {
        // Movement Code
    }

    if(InputManager.Instance.GetInputActionValue("Fire", InputActionState.WasPressedThisFrame)) {
        // Shooting Code
    }
}

All Methods

public bool AddInputActionReference(InputActionReference inputActionReference)
public bool GetInputActionValue(InputActionReference reference, out Vector2 value)
public bool GetInputActionValue(string inputActionName, out Vector2 value)
public bool GetInputActionValue(InputActionReference reference, InputActionState inputActionState)
public bool GetInputActionValue(string inputActionName, InputActionState inputActionState)
public InputActionReference GetInputReference(InputAction action)
public InputAction GetInputAction(InputActionReference reference)
public InputAction GetInputAction(string inputActionName)
public Vector2 GetMouseScreenPosition()
public void PerformInputActionRebind(InputActionReference inputActionReference, int bindingIndex)
public void PerformInputActionRebind(InputAction inputAction, int bindingIndex)
public string GetBindingDisplayString(InputAction inputAction, int bindingIndex)
public string GetBindingDisplayString(InputActionReference inputActionReference, int bindingIndex)
public string GetBindingDisplayString(string inputActionName, int bindingIndex)

inputsystemmanager's People

Contributors

nickk888samp avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.