Relative Content

Tag Archive for c#unity-game-engine

I need help creating mouse-centered zooming

I’ve been trying to make a system in my 2D unity game where you can zoom in and out by scrolling, and it should center that zoom around the cursor, like zooming in on a web browser. With the way the game is set up, I can’t alter the camera in any way so I’m attempting to do this mouse-centered zoom by positioning and scaling the transform that this script is attatched to (the camera is directly facing this GameObject). I have the scaling part down, but I’ve been trying to get the positioning to work for days and it just won’t work properly. Here is my code.

Unity new input system generating multiple events

I’ve just started learning Unity’s not-so-new input system. When pressing a button (which causes a UI element to appear and disappear), I’m receiving multiple button press events, which is causing the UI element to flicker (active / inactive) while the user presses the key (for example for a few microseconds). I have been attempting to find a solution that would cause just a single event to be fired regardless of how long the user holds down the key / clicks a button – for example when the key is initially pressed or is released. I have experimented with the Input System Interactions (notably Press: “Release Only” and Tap) but without success – I still get the flickering. I have also been reading about the .WasPerformedThisFrame method, but I can’t figure out how to use it.

Unity new input system generating multiple events

I’ve just started learning Unity’s not-so-new input system. When pressing a button (which causes a UI element to appear and disappear), I’m receiving multiple button press events, which is causing the UI element to flicker (active / inactive) while the user presses the key (for example for a few microseconds). I have been attempting to find a solution that would cause just a single event to be fired regardless of how long the user holds down the key / clicks a button – for example when the key is initially pressed or is released. I have experimented with the Input System Interactions (notably Press: “Release Only” and Tap) but without success – I still get the flickering. I have also been reading about the .WasPerformedThisFrame method, but I can’t figure out how to use it.

Unity new input system generating multiple events

I’ve just started learning Unity’s not-so-new input system. When pressing a button (which causes a UI element to appear and disappear), I’m receiving multiple button press events, which is causing the UI element to flicker (active / inactive) while the user presses the key (for example for a few microseconds). I have been attempting to find a solution that would cause just a single event to be fired regardless of how long the user holds down the key / clicks a button – for example when the key is initially pressed or is released. I have experimented with the Input System Interactions (notably Press: “Release Only” and Tap) but without success – I still get the flickering. I have also been reading about the .WasPerformedThisFrame method, but I can’t figure out how to use it.

Unity new input system generating multiple events

I’ve just started learning Unity’s not-so-new input system. When pressing a button (which causes a UI element to appear and disappear), I’m receiving multiple button press events, which is causing the UI element to flicker (active / inactive) while the user presses the key (for example for a few microseconds). I have been attempting to find a solution that would cause just a single event to be fired regardless of how long the user holds down the key / clicks a button – for example when the key is initially pressed or is released. I have experimented with the Input System Interactions (notably Press: “Release Only” and Tap) but without success – I still get the flickering. I have also been reading about the .WasPerformedThisFrame method, but I can’t figure out how to use it.

Unity new input system generating multiple events

I’ve just started learning Unity’s not-so-new input system. When pressing a button (which causes a UI element to appear and disappear), I’m receiving multiple button press events, which is causing the UI element to flicker (active / inactive) while the user presses the key (for example for a few microseconds). I have been attempting to find a solution that would cause just a single event to be fired regardless of how long the user holds down the key / clicks a button – for example when the key is initially pressed or is released. I have experimented with the Input System Interactions (notably Press: “Release Only” and Tap) but without success – I still get the flickering. I have also been reading about the .WasPerformedThisFrame method, but I can’t figure out how to use it.