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. Dismiss Notice

Question Active input handling from Both to Input System Package (New) and forbid the use of the old API

Discussion in 'Input System' started by bdovaz, Jan 25, 2023.

  1. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,010
    @Schubkraft mistakenly thought that when I changed from "Both" to "Input System Package (New)", Unity would stop referencing any assembly related to the old Input and get compiler errors on all the code that references that old API.

    The reality is that it doesn't, so my question is: how can we introduce a mechanism to avoid that someone keeps using the old API if the active input handling is not in "Both"?

    I see quite dangerous this behaviour because I imagine that the error will be a runtime error and this is something that is not easy to check/debug depending on the complexity of the project.
     
  2. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,067
    Sadly there is no easy way make it do what you are asking. It won't throw compile errors but it also won't work. So if your colleagues test their code they should see it not working.
    Sorry to not have better news.
     
  3. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,010
    @Schubkraft I thought there was going to be some kind of compilation directive that at least adding it manually would make it not compile the old API but I see that not even that.

    Well if you want developers and Asset Store publishers to switch to using the new API, this is not the way because wittingly or unwittingly, you can use (directly or indirectly) old API and not realize it.
     
  4. rdjadu

    rdjadu

    Joined:
    May 9, 2022
    Posts:
    99
    While not compile errors, you'll get runtime errors (with stacks) from the old API when used with input setting set to "new".
     
  5. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,010
    But it is precisely the complex thing, it is not easy to detect runtime errors but it is easy to detect compilation errors.