Need Help UI Button

Very simple question: I have a button that i want to set a value from a script to true while it is being pressed and to false when it is released. How can that be accomplished?

Easiest way would be using the event system, I’d look into unity’s free tutorial videos, theres a whole series over the new UI that goes into how events work, as well as other nice stuff. Addtionally there are alot of very cool tutorials in their weekly tutorials that go over UI, such as modular ui.

That seemed to have worked on the editor but not when i build it to the device the variables seem to be stuck on “true” when pressed almost every time.

What I did was create two UI buttons on both sides of the screen. They have an event trigger that says when Pointer Down to set the variable to true, and pointer up to set the variable to false. This is working on the editor without touch input, but is not working on device. It clearly is picking up touch input, but often, it gets stuck on true (not all the time) and takes a while to receive the touch input, and i need it to be almost instantly. Any idea why its not going right?

Well for a quick solution, you could have the button send a message to a script to run a boolean flip on whatever it is you’re trying to flip on and off, basically if = true, set false if = false, set true.