Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. 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