Having problems detecting both LMB and RMB at the same time. Is my mouse broken? - mouse

I am currently developing a game in Unity3D. One of the features in the game involves having both LMB and RMB pressed at the same time.
My problem is that I tested my code with my own mouse a Trust/15315 and it was not able to register both buttons pressed at the same time, but just the 2 of them individually. I then tested the same code with 3 other mouses and it worked perfectly.
My questions are: Is my mouse not working properly by being broken? Or is this a feature in my mouse? Are there other mouses that are built to act like this (not being able to detect both mouse buttons down at the same time)?
As asked I added the code used:
using UnityEngine;
using System.Collections;
public class Gestures : MonoBehaviour {
void Update () {
print (Input.GetMouseButton(0)+" "+Input.GetMouseButton(2) + " "+ Input.GetMouseButton(1));
}
}
Also I would like to add that the left and the middle buttons work together but the right doesn't work with the other two.

Hard to say if it's intended by Unity or not to get a clean single button click implementation across different mice and OSs.
I struggled with a similar problem and found out that it's more reliable to read the mouse button status from Input.GetMouseButtonDown and Input.GetMouseButtonUp events.

I then tested the same code with 3 other mouses and it worked perfectly.
It sounds like it is just your mouse. Tracking down the exact issue is tricky since there are so many steps in the process. (hardware -> onboard software -> wireless -> drivers -> OS -> Unity) Sloppy implementation at any point in that process could theoretically cause an issue like you described.
As others have mentioned, the mouse events can be a bit glitchy even in the best of times. The good news is that, depending on what exactly you need to do, there is usually a work around.
If you are aiming to handle single vs. double click this might be useful: simultaneous single and double click functions
If you are looking for click-and-hold sort of behavior you will likely want to look at mapping the mouse buttons via Input.GetAxis.

Related

Oculus integration Custom hand movements in my VR Unity project not working on my system

I am working in unity on creating a application for the the Quest VR system. (Quest2) and added the Oculus Integration Package to my project. (While following an online course)
When I try and use any of the custom hands provided in the package, or run any of the example scenes that use them, the finger movements follow my controller grip presses (hand trigger) perfectly making a semi fist with the bottom 3 fingers, but the index trigger presses do not seem to cause any animation. Neither does a thumb press.
I have added a crude Log to show the triggers are being picked up by the system, but the animation is not showing.
What makes this very vexing as I shared my project with the course provider I was following and it worked perfectly for him.
So the problem is on my system somewhere..
Implementing the same from scratch using the XRInteraction toolkit system works perfectly btw. But the Oculus provided system does not.
If anyone has any ideas on where to even begin looking for the problem I would appreciate it greatly.
Happy to share system details but not even sure which details would be relevant :)

Capturing game controller (not keyboard) input in Unity when the application is in the background?

In a nutshell, my goal is to create my own program for visually looking at game controller input.
However, it appears that once the unity application is in the background, ergo, once I switch to a different window to play a game, the controller input for my unity program is no longer read.
I've seen that the user Elringus had a project called UnityRawInput to help with this, but it only works for keyboard input. I've seen a lot of different responses related to this question that mention using native libraries to "hook" to get background input, but it apparently only works for keyboards.
What information is out there such that I can hook to game controllers themselves? I cannot seem to easily search for information pertaining to game controllers (and their various axis) themselves and not keyboards.
Why not a keyboard? Because I am very interested in a game controller's triggers in the way where, when pressed slightly, it can preform "weaker" actions rather than being pressed all the way, which a keyboard cannot discern as far as I can tell.
Though, wherever the solution might be, even outside of Unity, I'd like to know. Thanks! :D

Intercept Vive controller input?

I'm building an openvr app for steamvr to assist with seated play (my room is small so my tracking area isn't ideal). My app pretty much just adjusts the play-area height when I hold the grip button and "scroll" on the touchpad so that I can reach objects that are too low/high at variable heights. (I tried "OpenVR Advanced Settings" but the options for keybinding with it is limited to simple button presses so I decided to make my own version).
I'd like to prevent touchpad input from being sent to the game while the grip button is being held, so that the moving on the touchpad doesn't cause movement in game, is this possible at all?
I'm assuming it's not possible, but wondering whether anyone has had any experience with this.
After your clarification in the comments the answer is no, you can not "eat up" device inputs in an application, I usually work on OpenVR drivers and there after you submit a device input and/or any other event its available to anything that expects pose update events, and event subscribers can not stop others from receiving the said events
However there might be a work around (if its still an issue) I know of at least 1 application that can do what you want and that application is OVR Toolkit (when the overlay is active and you try to click something in the overlay, the game running in parallel will not receive the input, however that will only happen if OVR Toolkit overlay surface receives input, it may be a built in OpenVR overlay feature and you don't have to do anything or it can be defined by the developer, I don't really have a want to test this right now)
Sadly though OVR Toolkit is not open source, but there is an open source toolkit for unity for making overlays, which is open source and might be the solution you're looking for, it can be found here

Save data from game to editor? [duplicate]

Apparently this is some beginner's question (and that I am) but it's driving me crazy and I couldn't find any mention:
I Occasionally forget to exit Play mode and go on building my UI making objects and changes, only to realize that I'm still in Play Mode and as soon as I unpress the play button, these will be purged! I suppose the Unity Editor has its reasons for allowing editing of Scripts/Scenes while in Play Mode (would be happy to hear some examples-maybe testing scenes?) but my main question here is:
Is there some way for me to prevent this behavior? Or at least some trick that you use to prevent me from making changes while in play mode? (Other than becoming paranoid about it and checking constantly...)
Thank you
PS. sigh time to head back to Unity and rebuild that UI that I lost...
Other Unity coders have had this problem before me and they came up with a neat solution.
Setting the UI to a different colour while in playmode "Playmode tint".
You can read the details here (originally posted 2009 but I have checked it still works in latest Unity 5.3):
http://answers.unity3d.com/questions/9159/best-strategies-for-not-accidently-editing-whilst.html
There is no settings to prevent changing things during play mode but there are ways to reduce the chances of losing changes during play mode.
1.Edit->Preferences... -> Colors. Now, on the right change Playmode Tint to red. That will remind you you are making changes in play mode.
2.Click on the gear icon of each component you change during play then click Copy Component. When are done with playmode, select the component you want to keep its changes. Click the gear icon again and this time, Click Paste Component Values.
3.Write an Editor Plugin that will do that for you. This is hard but possible.
Use event to find out when entering playmode. Store all GameObject public important variables such as transform/rigidbody properties in a list.
Wait for the stop event to fire then ask your self which GameObjects to overwrite settings to. Then overwrite the properties of the selected GameObjects That's it.
Usefull APIs for this:
EditorApplication.isPlaying
EditorApplication.isPaused
EditorApplication.isPlayingOrWillChangePlaymode
EditorApplication.playmodeStateChanged += callBackFunc;
EditorApplication.HierarchyWindowItemCallback
EditorApplication.ProjectWindowItemCallback
Note: According to Unity roadmap, a feature that enables you to save playtime changes is in construction and will be released soon but the above seems to be the only way at this time.
You can select objects you want to keep while in play mode, copy them with Ctrl + C, and then just paste them back in with Ctrl + V after returning to edit mode. Then you can eithr delete the originals from the scene or copy values from individual components like #Programmer suggested.

Unity3d editor: how to prevent changes from being undone upon exiting play mode?

Apparently this is some beginner's question (and that I am) but it's driving me crazy and I couldn't find any mention:
I Occasionally forget to exit Play mode and go on building my UI making objects and changes, only to realize that I'm still in Play Mode and as soon as I unpress the play button, these will be purged! I suppose the Unity Editor has its reasons for allowing editing of Scripts/Scenes while in Play Mode (would be happy to hear some examples-maybe testing scenes?) but my main question here is:
Is there some way for me to prevent this behavior? Or at least some trick that you use to prevent me from making changes while in play mode? (Other than becoming paranoid about it and checking constantly...)
Thank you
PS. sigh time to head back to Unity and rebuild that UI that I lost...
Other Unity coders have had this problem before me and they came up with a neat solution.
Setting the UI to a different colour while in playmode "Playmode tint".
You can read the details here (originally posted 2009 but I have checked it still works in latest Unity 5.3):
http://answers.unity3d.com/questions/9159/best-strategies-for-not-accidently-editing-whilst.html
There is no settings to prevent changing things during play mode but there are ways to reduce the chances of losing changes during play mode.
1.Edit->Preferences... -> Colors. Now, on the right change Playmode Tint to red. That will remind you you are making changes in play mode.
2.Click on the gear icon of each component you change during play then click Copy Component. When are done with playmode, select the component you want to keep its changes. Click the gear icon again and this time, Click Paste Component Values.
3.Write an Editor Plugin that will do that for you. This is hard but possible.
Use event to find out when entering playmode. Store all GameObject public important variables such as transform/rigidbody properties in a list.
Wait for the stop event to fire then ask your self which GameObjects to overwrite settings to. Then overwrite the properties of the selected GameObjects That's it.
Usefull APIs for this:
EditorApplication.isPlaying
EditorApplication.isPaused
EditorApplication.isPlayingOrWillChangePlaymode
EditorApplication.playmodeStateChanged += callBackFunc;
EditorApplication.HierarchyWindowItemCallback
EditorApplication.ProjectWindowItemCallback
Note: According to Unity roadmap, a feature that enables you to save playtime changes is in construction and will be released soon but the above seems to be the only way at this time.
You can select objects you want to keep while in play mode, copy them with Ctrl + C, and then just paste them back in with Ctrl + V after returning to edit mode. Then you can eithr delete the originals from the scene or copy values from individual components like #Programmer suggested.