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

extensible InputSystemUIInputModule

Discussion in 'Input System' started by IAndrewNovak, Oct 2, 2019.

  1. IAndrewNovak

    IAndrewNovak

    Joined:
    Nov 29, 2013
    Posts:
    117
    Hello.
    Any plans for make InputSystemUIInputModule extensible ?

    for example:


    Code (CSharp):
    1. public class MyCustomModuleTest : InputSystemUIInputModule
    2. {
    3.      public float MaxInteractionDistance = 1.2f;
    4.  
    5.      override InputSystemUIInputModule methods here
    6. }
    Now it has no errors but nothing worked and missing all ui in inspector (see screenshots).



     
  2. IAndrewNovak

    IAndrewNovak

    Joined:
    Nov 29, 2013
    Posts:
    117
  3. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Makes sense. I've added a ticket (ISX-291) for this to get looked at after 1.0. Likely all we need is exposing InputSystemUIInputModuleEditor and making it apply to subclasses, too, by default.
     
  4. IAndrewNovak

    IAndrewNovak

    Joined:
    Nov 29, 2013
    Posts:
    117
    Good news! Thanks for reply Rene ^_^
     
  5. EthanFischer

    EthanFischer

    Joined:
    Feb 10, 2016
    Posts:
    46
    Any update on this? Need to add a simple log whenever a click happens. If the private methods in InputSystemUIInputModule were 'protected' it would be trivial!
     
  6. rdjadu

    rdjadu

    Joined:
    May 9, 2022
    Posts:
    112
    Not a great solution by any means but as a workaround, should be possible to just take the UI module source from the input system package, put it in your project in a different namespace and modify it to your liking.
     
  7. EthanFischer

    EthanFischer

    Joined:
    Feb 10, 2016
    Posts:
    46
    Hmm I actually tried that, but can't get it to compile for whatever reason. I changed the name of the class and the filename, changed the namespace, tried commenting out the compiler directive at the top of the class and saw a bunch of errors. *shrugs*
     
  8. rdjadu

    rdjadu

    Joined:
    May 9, 2022
    Posts:
    112
    Ah right, think it references some internal utility stuff.

    Final resort would be to just copy com.unity.inputsystem into the project's Packages folder (so it becomes an embedded package) and then change the modifiers to protected on InputSystemUIInputModule. Updating to new versions will be slightly more annoying but with a modification as minor as that, should be pretty painless still.
     
  9. 3dHomer

    3dHomer

    Joined:
    Jun 6, 2015
    Posts:
    14
    That's extremely confusing. Even the old InputModule was hard to deal with, but the new one is absolutely not customizable. Everything is private and internal.
     
  10. IAndrewNovak

    IAndrewNovak

    Joined:
    Nov 29, 2013
    Posts:
    117
    +1 Internal of internals :)
    I thought that the new input system would be easily expandable, but it turned out that the old one is easier to improve than the new one.

    Instead of rewriting the new input module, I created my own script to reproduce the old input code for world canvasses because if you mouse lock you cast from Vector2.zero coordinates. I need a cast from the center of the screen. Some features are not available, but it lives and works.
    How it works


    Also if you have World Canvases in the game you critically need the interaction distance parameter. I don't need to interact with displays from 100 meters away.
    Unity doesn't know it because not make games :D
     
    Last edited: Nov 5, 2023