Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Unity 2018.3 is now released.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

A button to shoot: How To ?

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

  1. SLASH24

    SLASH24

    Joined:
    Sep 20, 2012
    Posts:
    112
    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:
    112
    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:
    112
    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