Author Topic: EventDelegate throwing errors using anonymous delegates  (Read 4915 times)

dillrye

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 30
    • View Profile
EventDelegate throwing errors using anonymous delegates
« on: May 22, 2014, 11:17:50 AM »
Hello,
In Ngui 3.5 i was able to do this:
EventDelegate.Add(tween.onFinished, () => { HideTweenFinished(); });

But now its throwing this error after i upgraded to 3.6:

Could not find method '<Hide>m__AC' on MissionSelectBase

It also throws errors when doing this:
EventDelegate.Add(tween.onFinished,  HideTweenFinished);

where HideTweenFinished is a private function. 

It looks like its trying to do reflection at this point.  Why wouldn't it just keep a handle to the original function? 

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: EventDelegate throwing errors using anonymous delegates
« Reply #1 on: May 22, 2014, 04:09:20 PM »
There was a similar thread on this a few days ago, and had something to do with derived classes. Why can't you simply do EventDelegate.Add(tween.onFinished, HideTweenFinished); ?

The fact that it's private doesn't matter.

dillrye

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 30
    • View Profile
Re: EventDelegate throwing errors using anonymous delegates
« Reply #2 on: May 22, 2014, 04:33:58 PM »
It also throws an error calling the function. "Could not find method 'HideTweenFinished' on MissionSelectBase"  Its calling a function on the mono behavior the tween was run from.

I wanted to add, the ability to call a function with parameters doing () => { MyFunction(pos, target, 1, false); } was really handy.
« Last Edit: May 22, 2014, 05:16:51 PM by dillrye »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: EventDelegate throwing errors using anonymous delegates
« Reply #3 on: May 23, 2014, 04:42:58 PM »
I believe this should already be fixed in 3.6.1.