Search Unity

Static MyInputControls? Best practice

Discussion in 'Input System' started by douglassophies, Apr 24, 2020.

  1. douglassophies

    douglassophies

    Joined:
    Jun 17, 2012
    Posts:
    141
    I hate having this all over my code every time i want to catch some input:
    Code (CSharp):
    1. m_Controls = new MyInputControls();
    2. m_Controls.Enable();
    I was considering making it a singleton but i am not sure if that will become a hassle with it auto generating and i wonder if there is a good reason its not done like that by default?
    Also, maybe i have overlooked some deeper flaw in my code design that results in this being an issue for me where its not for others?

    Thoughts?



     
  2. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Using PlayerInput instead of generated C# classes will take care of the enabling and managing the asset.

    Not having a single global set of input actions was a conscious decisions due to the problems that the previous ProjectSettings/InputManager.asset caused. Might be we should add something to the input settings to make it possible to just drop an .inputactions asset in there and have it always be active.