Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

When should I create a new instance of my InputActions class?

Discussion in 'Input System' started by HugeWill, Sep 2, 2020.

  1. HugeWill

    HugeWill

    Joined:
    Nov 4, 2016
    Posts:
    27
    Hi,

    I've got 2 scripts : CameraController and Player
    Both classes currently on Start run

    Code (CSharp):
    1. private void Start() {
    2.         var inputActions = new InputActions();
    3.         inputActions.Enable();
    4.     }
    Is it best practice for these classes to share the same instance of InputActions?
    What's the pros/cons for having separate instances?

    Cheers,
    Will