Author Topic: How to change lambda to NGUI 3.0  (Read 2519 times)

yamazakida

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
How to change lambda to NGUI 3.0
« on: September 21, 2013, 12:46:47 PM »
I used  " _slider.onValueChange += x => isDirty = true;  "
but can't it way after NGUI 3.0 upgrade.

Answer Please.


(Sorry. I can use English a little bit.)

OnlineCop

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 51
    • View Profile
Re: How to change lambda to NGUI 3.0
« Reply #1 on: September 21, 2013, 02:54:13 PM »
I'm going off of 2.7.0, so can't help with 3.0 directly, but does onValueChange take parameters? For 2.7.x, .onPress took both GameObject and bool, so I would write its lambas as:
myButton.onPress += (go, state) => { isDirty = true; };
Do parentheses make any difference (" += (x) =>"  vs. " += x =>" ) ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to change lambda to NGUI 3.0
« Reply #2 on: September 21, 2013, 07:20:42 PM »
EventDelegate.Add(myButton.onPress, YourFunction); -- I've never tried using embedded functions like that, so I wouldn't know. Just make it a function.

nugao

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: How to change lambda to NGUI 3.0
« Reply #3 on: September 22, 2013, 03:03:02 AM »
Hello, just do "() => { somecode; }" , but I think lambda is uglily for void parameter.