Search Unity

A button to shoot: How To ?

Discussion in 'UGUI & TextMesh Pro' started by SLASH24, Jan 17, 2015.

  1. SLASH24

    SLASH24

    Joined:
    Sep 20, 2012
    Posts:
    144
    Hi there,
    I'm working for mobile platforms (touch screen devices) and I use Unity 4.6 UI...
    What I'm trying to do is simple: a UI button, when you press it, the in-game gun fires/shoot and once you stop pressing button (stop touch the screen) : the gun stops to fire !

    unfortunately, I can't do this properly alone, I spent a lot of time on it, trying to understand how to do. Spent time searching the web and this forum also !
    the problem is that I can detect when the button start to be pressed but I don't know when it's released

    my question is : what is the simple way to know when a UI Button is released, (no longer touched/pressed) (on mobile devices) ?
    Thanks in advance !! :)
     
  2. SLASH24

    SLASH24

    Joined:
    Sep 20, 2012
    Posts:
    144
    hey, guys!
    it's okay now, I found out !
     
    nathi0106 likes this.
  3. rezki

    rezki

    Joined:
    Oct 15, 2013
    Posts:
    53
    Make your shooting a public function
    Then, there where it sais onClick on the Button component select your object and your function
    osaB5mR.jpg
     
  4. nathi0106

    nathi0106

    Joined:
    Aug 22, 2018
    Posts:
    4
    Hi..Im trying to do the exact game which is to shoot using a button..My problem is when i click the button, the log says it is shooting, but i don't see any particles coming out... can you help?
     
  5. SLASH24

    SLASH24

    Joined:
    Sep 20, 2012
    Posts:
    144
    nathi0106 likes this.
  6. nathi0106

    nathi0106

    Joined:
    Aug 22, 2018
    Posts:
    4
    Thank you sooo much..But i'm following another tutorial right now. If this doesn't work, then i will check it out..Sorry, i give up easily..haha XD