Author Topic: UIButton touch device - New User.  (Read 3276 times)

PiotrT

  • Guest
UIButton touch device - New User.
« on: September 12, 2012, 10:30:31 AM »
Hi I just bought NGUI and I'am trying to use it instead of Unity Gui in my game. It's iOs.
I have moveoperator script with all character moves and two GUITextures which touch listeners attached .
Instead of them I want to use NGUI Buttons.

I have two questions :
1.Should I make a new script and attach to UIRoot, Camera, Anchor, Panel, Button and then correspond to my moveoperator script and starts all moves?
2. How to write this condition --- touch.phase ==TouchPhase.Began || touch.phase == TouchPhase.Stationary using onClick(), onPress() I mean NGUI Button events.

Thank you in advance
BTW
Really nice plugin.

Malzbier

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 93
    • View Profile
Re: UIButton touch device - New User.
« Reply #1 on: September 12, 2012, 11:14:49 AM »
Just make a  New script Script and attach it to the button

  1. OnPress (bool isPressed)
  2. {
  3. if(isPressed)
  4. {
  5.  /// inform your moveoperator that the buttons has been start to been pressed.
  6. }
  7. else
  8. {
  9. /// inform your moveoperator that the buttons has been stopped to been pressed.
  10. }
  11.  
  12. }
  13.  
  14.  

PiotrT

  • Guest
Re: UIButton touch device - New User.
« Reply #2 on: September 12, 2012, 11:29:03 AM »
wow it, was simple thank you Malzbier
So basically right now I, don't have to write any statements Touch.Began and so on . All is cover by NGUI right ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButton touch device - New User.
« Reply #3 on: September 12, 2012, 02:33:51 PM »
Yup, NGUI takes care of it.

PiotrT

  • Guest
Re: UIButton touch device - New User.
« Reply #4 on: September 12, 2012, 04:02:19 PM »
Thank you...
One more thing, if I have for example two buttons should I have create two scripts to control them or I can create one script and call each button by  hmmm tag or id or name ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButton touch device - New User.
« Reply #5 on: September 12, 2012, 04:11:03 PM »
Depends on whether the code would be shared or not. Is the functionality the same? Then you can use the same script on both. Is it different? Then you need different scripts.