Hey, I’m currently trying to script a button to be my weapon trigger. I have several ui buttons in the scene. If in my trigger script I use onpointerdown it does what I need but affects all ui buttons. Is there a way to make onpointerdown affect only the ui in the script? Similar to tagging game objects? Or, how can I script the button that when the button is pushed it sets fire. Right now it only shoots when the button is released without using onpointerdown. Seems simple but I’m pretty new to scripting. I’m using a ray as my shot. I can post my script later, right now I’m on a mobil device
If you create a single script with all of the functions your buttons need, then attach that script to the canvas. On the button gameobject you can link the button click to the functions within the script attached to the canvas. This can be done all in the Unity UI.
For clarity, this canvas should be the canvas up the tree from that button.
Yeah I’m aware of that method but it doesn’t apply for what I’m needing. Thanks though.