Author Topic: OnSelect Message Error  (Read 5734 times)

Rafe

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 78
    • View Profile
OnSelect Message Error
« on: August 19, 2012, 12:09:51 PM »
I've been getting this for some time but just got around to reporting it as it wasn't blocking. I'm not really sure where to begin debugging since it starts in Update() and I don't know anyway to follow a message. In other words, I'm not explicitly calling this code.

It seems to happen every time I switch between clicking on nGUI layers and "fall-through" layers. In real terms: My first click on the UI will trigger this error, then if I click around the UI it doesn't happen again... if I then click in the game I get the error, but as I click around the game I don't see it again, then if I click back in the UI, I see the error, etc....

MissingMethodException: The best match for method OnSelect has some invalid parameter.
  1. MissingMethodException: The best match for method OnSelect has some invalid parameter.
  2. System.MonoType.InvokeMember (System.String name, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object target, System.Object[] args, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, System.String[] namedParameters)
  3. UnityEngine.SetupCoroutine.InvokeMember (System.Object behaviour, System.String name, System.Object variable) (at C:/BuildAgent/work/d9c061b1c154f5ae/Runtime/Export/Coroutines.cs:18)
  4. UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
  5. UICamera:Notify(GameObject, String, Object) (at Assets/NGUI/Scripts/UI/UICamera.cs:540)
  6. UICamera:ProcessTouch(Boolean, Boolean) (at Assets/NGUI/Scripts/UI/UICamera.cs:991)
  7. UICamera:ProcessMouse() (at Assets/NGUI/Scripts/UI/UICamera.cs:787)
  8. UICamera:Update() (at Assets/NGUI/Scripts/UI/UICamera.cs:648)
  9.  

Cheers,

- Rafe

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnSelect Message Error
« Reply #1 on: August 19, 2012, 12:17:56 PM »
It means you have a function that has the same name it expects, but not the same signature. Our line numbers don't match so I can't tell you what function that is. Go to UICamera line 540 and you should be able to see it. Then do a search to see where it's used. One of your functions is not going to have the same signature as others. For example, instead of:
  1. void OnSelect (bool isSelected)
...you have:
  1. void OnSelect (GameObject something)

Rafe

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 78
    • View Profile
Re: OnSelect Message Error
« Reply #2 on: August 19, 2012, 04:27:58 PM »
That is the latest UICamera script as far as I know. I just updated from the Asset Store. I did not edit the code (I never do, I always copy code if I am going to work on a third party plugin)

I know what the error means ;) I posted the traceback as part of a bug report. Here is the line in Notify at line 540:
  1.     static void Notify (GameObject go, string funcName, object obj)
  2.     {
  3.         [...snip....]
  4.             go.SendMessage(funcName, obj, SendMessageOptions.DontRequireReceiver);   // <----- line 540
  5.             [...snip....]
  6.  
I searched for all references and it looks like UICamera is the only script that runs this. The lines that I see that run Notify with an "OnSelect" message are:
  1. ...NGUI\Scripts\UI\UICamera.cs - (305, 7) : Notify(mSel, "OnSelect", false);
  2. ...NGUI\Scripts\UI\UICamera.cs - (322, 7) : Notify(mSel, "OnSelect", true);
  3. ...NGUI\Scripts\UI\UICamera.cs - (991, 7) : Notify(currentTouch.pressed, "OnSelect", true);
  4.  

Note they all pass a bool but the function takes an object. Is bool derived from object?
« Last Edit: August 19, 2012, 04:31:03 PM by Rafe »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnSelect Message Error
« Reply #3 on: August 19, 2012, 04:31:26 PM »
You may have the latest, but I'm on 2.1.5 which has not yet been released. ;)

Edit: Nm, I see what you mean. "object" is generic, so it should work fine.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnSelect Message Error
« Reply #4 on: August 19, 2012, 04:34:15 PM »
It all works fine on my end. Do you have an "OnSelect" function somewhere in your code that doesn't have a "bool" parameter?

Rafe

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 78
    • View Profile
Re: OnSelect Message Error
« Reply #5 on: August 19, 2012, 05:25:25 PM »
Yes, found it!!

Changed mine to OnSelected and the error is gone.

I wish Unity would print something helpful since they made the call so generic!

Thanks for the help.