Author Topic: UIButton event do not support polymorphism method  (Read 2632 times)

chukaishing

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
UIButton event do not support polymorphism method
« on: October 16, 2016, 04:02:47 PM »
I has two method like that
public void Foo () {
}
public void Foo (string str) {
}

I try to add Foo () to UIButton on click event, and I get this error:
"Could not find method 'Foo' on FooScript"

NGUI version is 3.10.2

This is a bug? and that will fix in future?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButton event do not support polymorphism method
« Reply #1 on: October 17, 2016, 10:21:22 PM »
You should have them uniquely named. The script that finds the delegate by name is pretty rudimentary. I was only learning reflection back when I wrote it. Just keep them named differently.

chukaishing

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UIButton event do not support polymorphism method
« Reply #2 on: October 18, 2016, 07:08:53 AM »
You should have them uniquely named. The script that finds the delegate by name is pretty rudimentary. I was only learning reflection back when I wrote it. Just keep them named differently.

Tanks for your reply.
In my case, Foo() and Foo(string) must be exist.
I just add a method like that to fix now:
void FooForNGUI () { Foo(); }

I want to know, the reflection problem will fix in future?
If yes, I will still to waiting the update.