Search Unity

Unity native button support for multitouch?

Discussion in 'Scripting' started by udik, Jan 28, 2015.

  1. udik

    udik

    Joined:
    Oct 9, 2013
    Posts:
    37
    Hi guys,

    Is there any way to make native Unity buttons play nice and not cancel each other when being pressed simultaneously on Android? I know I can use Texture and touch events but will be much easier to simply use native Unity buttons..

    Thanks!
    Udi
     
  2. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    What do you mean by "native Unity button"? Do you mean GUI.Button(...) in OnGUI()? If so then, no, because that's not a multi-touch system, it only emulates mouse input by averaging all touches. You could write your own button function with multi-touch support, of course.
     
  3. udik

    udik

    Joined:
    Oct 9, 2013
    Posts:
    37
    Yup both - you can only call GUI.Button from within OnGUI() function.. anyway GUI.Button works fine on mobile devices (I am testing on Android) so it does respond to touch events. I think the GUI.Button is just a glorified GUITexture under the covers, and GUITexture does support multutouch so I don't understand why Unity does not allow this. Thanks!
     
  4. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    GUI.Button does indeed work on mobile devices and respond to touch, but as I said it's touch input treated as emulated mouse input. Mouse input only has one pointer, so when there are multiple pointers (ie: more than one touch) it averages them all out.

    If you mean GUITexture as in the thing you can attach to a GameObject, that's quite different. If you mean as in GUI.DrawTexture (which is what I'd use to roll my own multi-touch button) then that has nothing to do with touch, input or picking, it just draws a texture and it's up to other code to do anything else.