- Home /
UI button SetActive() resets the Onscreen stick position.
I am making a game for Mobile and am trying to make an on screen button appear and disappear when my character enters a collider trigger. I am using button.SetActive(true/false) function to make the button appear and disappear. The button seems to work fine and it does show and hide as expected. But I am experiencing a very weird and different problem. Every time the setActive for the button is called, the on Screen Joystick position resets itself to center stopping my character immediately. My controls are supposed to be very sensitive.
To fix this I tried to put the button on a separate Canvas. Still the same.
The problem exists on the Unity Game window when I use my mouse to move the on screen Joystick as well as on the mobile.
Any clues on why this is happening and how to fix it?
I am using Unity 2020.1.2f1 Personal
am using the New Input System with On-Screen Stick Component and overriding "Left Stick of Gamepad" for joystick.
am using OnTriggerEnter/OnTriggerExit fuctions to SetActive(true/false)
Answer by vinimaykaul · Oct 07, 2020 at 07:35 AM
I found a working solution. Maybe it's not the best approach but this is what I did.
I added a component to my existing onscreen button.
I am using the Button component's features to hide the button.
I use setIntractable to true and false instead.
It works fine now.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
EventSystem.IsPointerOverGameObject doesn't work on virtual joystick (mobile) 0 Answers
Move player between 3 given points only by touching on the left/right side of the screen 1 Answer
Joystick isn't recognize by Unity when i activate CardBoard option 0 Answers