Unity (new) InputSystem does respond to mouse clicks - c#

I am building this simple game, where a bunch of fellows that I have are supposed to seek a point indicated by a mouse click. The issue is that the Editor does not seem to notice mouse clicks at runtime. I have used the exact Input Action Asset before for detecting presses of "g" button, but it seemed to have stopped working when I played with it some more sometime later. I have since removed the asset and created w new Action Assets (one that I created manually and another that I created through the Input Action component button). Neither of them works. I have no idea what is going on and I have been looking at this for several hours now. Can someone please explain what I might have done wrong?
Different functions I used to try and get the Editor to respond to my code are below. MouseClick() is the original function that I needed to run, but did not work, onFire() is my attempt at running the default one that is given if Actions Asset is isnantiated through the component.

So it turns out that the issue was that the functions are supposed to be capitalized at the start.

Have you tried using the performed event ?
Also your Fire action needs to be a button type

Related

For some reason a UI button doesn't work in unity

I am making a game, and I ran into a problem.
For some reason a UI button doesn't work.
I tried to do a lot, but it didn't work
Here is a video that showing what happen:
https://drive.google.com/file/d/1wRZNvK63XrK93PGe92lZcs8CKCYVSvts/view?usp=sharing
Looks like your video link needs some kind of authentication.
So, Is there any error pops up?
make sure you did assigned your script to your button and set the On Click() event.
Need more info about your problem. screenshot or gif image might be ok.

Determine which mouse trigger the Click event in multiple mouse using C#? [duplicate]

I want to detect when my touchpad is clicked!
I normally use a usb mouse, so I don't use the touchpad for anything. Instead I'd like to make it possible to perform an action in .NET, when the touchpad is clicked. This way I can use it as a shortcut: One tap and something cool happens.
Is this possible, and if yes, any clue how? I'd prefer if it could be working in VB.NET or C#.
My theory is that I'd have to make a mousehook, which then somehow determines which device the click is coming from. If the click is determined to be from the touchpad, then cancel the click and doWhatever().
Thanks!
* EDIT *
Well, it's "solved", sort of :) In a odd coincidence, Synaptics released their latest driver and software for their touchpads a few days ago with some new functionality. As my laptop has a synaptics touchpad, I tried out the software and interestingly enough, the functionality for designating clicks on the trackpad to perform an action, was built-in.
So the desired function has been achieved, without a line of code (my own code anyway :).
Answer goes to Adrian though for the link to the RawInputSharp library. I tinkered with it yesterday, and I'm 90% sure it would be possible to use for this purpose, in the event a laptop doesn't have a synaptics trackpad.
Have a look at the RawInputSharp library from this page. It uses pInvokes into User32.dll to get hold of input device information. Using it you can detect which device (ie. mouse) input is coming from.
Having had a little play with it, I managed to extract some code that displays just the device id - a different value depending on whether I use my USB mouse or my internal touchpad. The tricky thing would be to identify which device id is that of your touchpad automatically, but you could manually configure this in your application.

Button no longer working in game window, but works fine in .exe build

So last night my game was working just fine. I log on today and I change an (unrelated) sprite and now for some reason the button won't be clicked in the game window during play mode. It does however work perfectly on an .exe build.
It's just the button that both players hit to say that they are ready to play the game.
Here are the relevant pieces of code pertaining to this button. The code that makes the button the code the button calls, etc.
https://gist.github.com/robofriven/ce26f24204dc0149c793
Sorry if this has already been asked, I do a lot of searching before asking questions and thus haven't had to ask anything yet, but this one has me stumped and I can't find anything similar anywhere. Thanks in advance for any and all help!
I figured it out. Apparently it has to do with the screen resolution not set to free aspect and that tweaking how the buttons respond to mouse clicks. It's kind of a phantom mouse thing where the mouse is not really pointing where it thinks it's pointing.

C# Event getting Triggered from same Event to Create it

I am using a Input system which manages input from all controllers, keyboard, etc. If you would like to check it out visit: http://mquandt.com/blog/2010/01/xna-input-manager-sample/
I have modified that input manager to have a queue system so that (in theory) would stop the event triggering to boil over when in the middle of a update.
Here is a bare bones example of my issue (This uses the XNA 4.0 framework):
http://www.mediafire.com/?9ynabpvls19u0sq
To explain my problem better if you don't want to download:
An input bind is created. After trigger the bind is deleted and a new one is added. But the same button press to delete and add the new one triggers the one that was added. This cycle continues with any number of binds. One->Three
What should happen is that on button press, old one is deleted and new one is added. Then after another button press add, delete, etc. One->Two->Three
I have figured out that if I add a breakpoint or a thread sleep of 100ms on the ActionDown of InputAction then it works correctly. I guess something is going wrong because it is going too fast but a thread sleep is not a solution.
Make DeActivate method where you can UnBind or destroy or disable your action.

detect printscreen

simply put I want my program which runs in the background to check whether the print screen button has been pressed (which mostly triggers a function within another program to generate a screenshot of the current window. eg a game screen).
I have seen lots of possible answers, but most seem overkill for just detecting the print screen button.
I want to have a program in the background check so that it can move the screenshot that has just been made/saved to a certain location. after the button had been pressed.
I hope this question is clear, if not I'll try to explain more clearly.
ps
On a side note, would it be better to try and detect the printscreen button or to simply check the specified folder every 1 or 5 minutes whether a new image has been put in that folder and then move it if true.
EDIT
I decided to use the FileSystemWatch, however it seems to be to fast if i use the on create event as sometimes the file is still being made and it can't move the file yet.
Would the best action be to use a timer to delay ?
You could just watch the folder location for updates using a FileSystemWatcher. There are many examples around the place.
Global keyboard capture in C# application
You should be able to use a global key hook to handle the print screen key press.

Categories