De-Panther / unity-webxr-export

Develop and export WebXR experiences using Unity WebGL
https://de-panther.github.io/unity-webxr-export/
Apache License 2.0
1.01k stars 106 forks source link

How to tell if a button is pressed or get joystick input? #291

Closed 253153 closed 11 months ago

253153 commented 12 months ago

How do I tell if a button is pressed on on oculus quest 2, or if there is joystick input? What do I need to add in ControllerInteraction.cs? Any advice would be highly appreciated! Thank you.

hugodigio commented 11 months ago

Same problem here. I guess we need to use WebXRController class reference on our script to handle Input, but current assembly definition of @De-Panther 's package don't permit that anymore.

using WebXR; don't work, so we can't reference WebXRController too.

hugodigio commented 11 months ago

the way to bypass the limitation for now, I think, is to download (or clone) the repo of WebXR Export and WebXR Interaction, and add manually into your project folder (but you will not have any update). With this method, you will don't have missing assembly reference limitation I guess. I haven't tried this method yet, I'm waiting a response of @De-Panther about this before, but if you're in a hurry, you can maybe try this @253153

De-Panther commented 11 months ago

Ignore @hugodigio suggestion to clone the repo.

Use assembly definition to reference WebXR asmdef file, and then in your script reference WebXR.WebXRController. You can look how ControllerInteraction call WebXRController to get button down/up state. There's similar method for thumbstick

hugodigio commented 11 months ago

Ok. So, If I understand, you suggest to:

But when we do this, all assembly references of all my project's packages doesn't work anymore. Maybe I missing something to do ... I'm not expert with this things. image

the fact is, I think, your package assembly definition has no "auto-referenced" box checked, so it's not automaticly added to unity references. image

De-Panther commented 11 months ago

No. Read Unity manual.

And as I wrote, "Add Assembly Defenition to Reference WebXR asmdef file". You actually have a screenshot of an asmsef file that references others. Just put one on your scripts folder and reference the relevant file.

The WebXR Assembly Defenition file is not auto referenced by design. Read Unity's manual for all the reasons why.

hugodigio commented 11 months ago

I'm sorry, but I had not found what you talking about in Unity Manual, of course I tried to look in the Unity manual before answering, but I couldn't find a page explicit enough to help me (I wouldn't have asked for help otherwise), even my lack of English had something to do with it ... I'm probably an idiot non-expert user, thx for your kindness.

So, I finally understand what we need to do, for other non-expert people have this little problem and don't found an explicit tutorial or right entry in Unity manual to how this things works, indeed it's not very hard to fix, you just need to know how this part of scripts working ^^ (it was not my case, I'll sleep better tonight):

  1. Create a folder in your project's "Assets" folder that will containing all your scripts that use the webXR @De-Panther package scripts
  2. in this folder, create an "Assembly definition reference" into that folder by right clicking on this folder > "Assembly definition reference" (my error was to create this "assemby definition reference" asset into root 😓 because "Assembly defintion Reference" will be applied on the folder where it is and all sub-folders) image image
  3. click on the asset created, in "assembly definition" line in inspector, drop WebXR asmdef file into it image
  4. now create all your scripts that use WebXR class reference in that folder that contain assembly definition reference image

thx @De-Panther to maintain this project alive ! Sorry for my wrong recommandations, trying to help despite my level being lower than yours 😖

De-Panther commented 11 months ago

I don't think it's an issue or level. And it's great that you are trying to help. You are not an idiot and don't call yourself like that.

It's just that those issues are related to how Unity works, and there is lots of material about it both on Unity manual and on the internet in general.