#How to detect input from unity new input system 11.x and XR interaction toolkit 3.0.6

1 messages · Page 1 of 1 (latest)

modern nacelle
#

I'm am trying to subscribe a function to a input action asset or detect a boolean value so I can trigger functionality. How does one go about reading input, in my case, of quest 2 controller, using ECS. I looked some videos from TMG and still unsure how things work.

From my understanding an InputActionReference is a managed value so it seems the only way is to add that componentdata class value to an entity and somehow . Add the referece to the authoring script and sub subscribe in the OnStartRunning on the ISystem. Or is it only possible in the SystemBase?

If I can get some insight, let me know if the above way is "correct" and am I suppose to only use ISystem or SystemBase as how I understand it, SystemBase is used when there are managed values involved so it seeems to be the use case here but I only need to read data and not write so I wonder if I can get away with using ISystem, as I try to use I System instead of systembase as much as I can but maybe that is the wrong mentality.

Appreciate any confirmation or insight, or links to any good samples or resources for interacting with the new input system with ECS. And I apologize in advance if my question is unclear or too trivial in advance.

sharp jasper
#

I have a whole source genned solution around this if you want

#

Even if you don't use it, it might give inspiration on how to implement yourself

#
    public partial struct InputCamera : IComponentData
    {
        [InputAction]
        public bool Turbo;

        [InputAction]
        public float2 Move;

        [InputAction]
        public float MoveY;

        [InputAction]
        public float2 Look;

        [InputActionDelta]
        public float2 ControllerLook;

        [InputAction]
        public bool LookEnable;

        [InputAction]
        public bool LookEnableAlt;

        [InputAction]
        public float Zoom;

        [InputAction]
        public ButtonState ConfinedOverride;
    }```
basically for example you just define this
#

and that's it

#

from there it just source generates everything else and exposes them via settings here

#

so yeah i just use systembase for this, events into isystem cause issues to say the least 🙈

modern nacelle
# sharp jasper I have a whole source genned solution around this if you want

interesting! thanks for getting back, and will have your solution a good look, appreciate it.

I never new there was an [InputAction] and [InputActionDelta] attribute is this part of the Entities package, I'll have to find it.

Anyway, I've never tried the source genned feature, is it something I have to generate myself? Or is it automatic since you said source gen. I know if I go to some folder or something in visual studio I can see the generated code, but it sounds like we get to implement our own code generation attribute?

so if I make a component similar to yours it will generate the system code for me? I will have to look into the gitlab for details later.

#

I also don't seem to have the same settings as you as I am using unity 6000.9.24f1 not sure this would make a difference but just mentioning

#

let me know if I misunderstood anything but my usecase right now is just trying to get something simple to work and learn how others do it "correctly". For the quest 2 XRI input asset.

sharp jasper
#

the settings are also part of my package

#

i'm just showing you how i implement it with source generators (which are publicly available)

modern nacelle
#

ahh I see so I'll have to install it via the link then gotcha gotcha thanks

#

will also check out the impl

sharp jasper
#

yeah i'm more jsut posting so you can see how i do it

#

can copy/inspiration/discard as you like

#

using the library is up to you