Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    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,042
    @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,070
    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,042
    @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:
    114
    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,042
    But it is precisely the complex thing, it is not easy to detect runtime errors but it is easy to detect compilation errors.