Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Joystick and Gui.Button not working at the same time

Discussion in 'Scripting' started by Ouss, Jan 25, 2014.

  1. Ouss

    Ouss

    Joined:
    Dec 26, 2012
    Posts:
    21
    Hello,
    I have a problem with my game on Android: When I press on a GUI.button it works nice, but when I move the joystick and then press the button at the same time, it doesn't work. How can I move my player with the joystick and can still be able to press the button.
    Thank you.
     
  2. seejayjames

    seejayjames

    Joined:
    Jan 28, 2013
    Posts:
    685
    AFAIK the GUI.buttons aren't multitouch-enabled, so if your joystick is virtual, that takes up the single press. You need to use a custom button/texture/rect that has multitouch enabled (use Input.TouchCount etc.)
     
  3. Ouss

    Ouss

    Joined:
    Dec 26, 2012
    Posts:
    21
    Actually I found a way to do so using Input.TouchCount. I had to put the block of code in the Update in order to make the multi touch works and not in the OnGUI as I did.
     
  4. MihajloNen

    MihajloNen

    Joined:
    Dec 7, 2015
    Posts:
    17
    hey guys, I have the exact same issue! Could you be so kind and post your piece of code that solved the problem? @Ouss
    I am new to mobile development and really appreciate your help