Author Topic: Anyway to send parameters using UIButton (or similar?)  (Read 2623 times)

pixeluche

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Anyway to send parameters using UIButton (or similar?)
« on: January 22, 2014, 06:43:19 PM »
Hello everyone,

I wonder if, is possible send parameters through UIButton or similar component, I didn't find a way to do that, I mean, a specific component that allow you send them to a method.

Thanks for your responses.

kitgui

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: Anyway to send parameters using UIButton (or similar?)
« Reply #1 on: January 22, 2014, 07:17:34 PM »
UICamera.currentTouchID tells you which button was clicked.

Without more context, I can only assume you want to know which button was clicked.

pixeluche

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Anyway to send parameters using UIButton (or similar?)
« Reply #2 on: January 23, 2014, 06:25:25 PM »
You are right kitgui and thanks for your response,  now I want to know what button was clicked...?

I already check what you tell me, but the documentation say:

Quote
ID of the touch or mouse operation prior to sending out the event. Mouse ID is '-1' for left, '-2' for right mouse button, '-3' for middle.

It`s an static integer variable, it returns me a integer... how could I use to know what button was clicked?

below say

Quote
OnClick () is sent with the same conditions as OnSelect, with the added check to see if the mouse has not moved much. UICamera.currentTouchID tells you which button was clicked.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Anyway to send parameters using UIButton (or similar?)
« Reply #3 on: January 24, 2014, 10:34:26 AM »
OnClick() is a generic NGUI event. It's not associated with any UIButton. All colliders can receive this event, and all other events.

UIButton script listens to this OnClick() notification and has an "On Click" delegate, which lets you choose a custom function instead, for example "MyCustomClick". To get the button that called it, use UIButton.current.
  1. public void MyCustomClick() { Debug.Log(UIButton.current.name); }

pixeluche

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Anyway to send parameters using UIButton (or similar?)
« Reply #4 on: January 24, 2014, 01:55:39 PM »
Thanks ArenMook!